schema

graphql
type User {
    id: ID!
    name: String!
    email: String!
    posts: [Post!]!
    createdAt: String!

GraphQL API with Spring Boot

java graphql spring-boot
by David Kumar 3 tabs
php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Laravel database migrations for schema management

laravel migrations database
by Carlos Mendez 3 tabs
ruby
# Create table migration
class CreateUsers < ActiveRecord::Migration[7.0]
  def change
    create_table :users do |t|
      t.string :email, null: false, index: { unique: true }
      t.string :name, null: false

Database migrations and schema management

ruby rails migrations
by Sarah Mitchell 2 tabs
sql
CREATE TABLE users (
    id BIGSERIAL PRIMARY KEY,
    username VARCHAR(100) NOT NULL UNIQUE,
    email VARCHAR(255) NOT NULL UNIQUE,
    password VARCHAR(255) NOT NULL,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

Database migration with Flyway

java flyway database-migration
by David Kumar 6 tabs
typescript
import { z } from "zod";

const booleanFromString = z.preprocess((val) => {
  if (typeof val !== "string") return val;
  return ["true", "1", "yes", "on"].includes(val.toLowerCase());
}, z.boolean());

Typed env parsing with zod

typescript zod validation
by codesnips 3 tabs
ruby
class CreateSubscriptions < ActiveRecord::Migration[7.1]
  STATUSES = %w[pending active past_due canceled].freeze

  def change
    create_table :subscriptions do |t|
      t.references :account, null: false, foreign_key: true

Schema-Backed Enums (DB Constraint + Rails enum)

rails postgres schema
by codesnips 3 tabs
python
from alembic import op
import sqlalchemy as sa

revision = "20240612_add_status"
down_revision = "20240515_create_orders"
branch_labels = None

Zero-Downtime NOT NULL Column Backfill with Alembic and SQLAlchemy

alembic sqlalchemy migrations
by codesnips 2 tabs
python
import pandera as pa
from pandera.typing import Series

class ChurnTrainingSchema(pa.DataFrameModel):
    customer_id: Series[int] = pa.Field(unique=True)
    age: Series[int] = pa.Field(ge=18, le=100)

Data validation contracts with Pandera for pipeline reliability

pandera data-validation schema
by Dr. Elena Vasquez 1 tab