Quick start
1. Install
Section titled “1. Install”npm install @smplcty/schema-flow2. Initialize project structure
Section titled “2. Initialize project structure”npx @smplcty/schema-flow init --dir ./schemaThis creates:
schema/├── tables/├── enums/├── functions/├── views/├── roles/├── mixins/├── pre/└── post/3. Define a table
Section titled “3. Define a table”table: userscolumns: - name: id type: uuid primary_key: true default: gen_random_uuid() - name: email type: text nullable: false unique: true - name: name type: text nullable: false - name: created_at type: timestamptz nullable: false default: now()indexes: - columns: [email] unique: true4. Preview the plan
Section titled “4. Preview the plan”npx @smplcty/schema-flow plan --db postgresql://user:pass@localhost:5432/mydbThis shows what SQL will run without executing anything.
5. Run the migration
Section titled “5. Run the migration”npx @smplcty/schema-flow run --db postgresql://user:pass@localhost:5432/mydb6. Check status
Section titled “6. Check status”npx @smplcty/schema-flow status --db postgresql://user:pass@localhost:5432/mydb7. Detect drift
Section titled “7. Detect drift”After manual DB changes or other tools modify the schema:
npx @smplcty/schema-flow drift --db postgresql://user:pass@localhost:5432/mydbAdopting on an existing database
Section titled “Adopting on an existing database”Generate YAML from your current database:
npx @smplcty/schema-flow generate --db postgresql://user:pass@localhost:5432/mydb --output-dir ./schemaThen baseline so the tool knows the current state is already applied:
npx @smplcty/schema-flow baseline --db postgresql://user:pass@localhost:5432/mydbUsing environment variables
Section titled “Using environment variables”Instead of passing --db every time:
export DATABASE_URL=postgresql://user:pass@localhost:5432/mydbnpx @smplcty/schema-flow plannpx @smplcty/schema-flow runOr use SCHEMA_FLOW_DATABASE_URL (takes precedence over DATABASE_URL).