Use when working with database migrations in a Stacks application — creating migration files, running migrations, fresh migration (drop + recreate), seeding after migration, migration file naming conventions, or the 96+ built-in migration files. For the database API itself (queries, connections, SQL helpers), see stacks-database.
Schema change management via migration files.
database/migrations/ (96+ files)config/database.tsbuddy migrate # run pending migrations
buddy migrate --diff # show SQL without running
buddy migrate --auth # include auth tables
buddy migrate:fresh # drop ALL tables and re-migrate
buddy migrate:fresh --seed # drop, migrate, then seed
buddy migrate:dns # DNS-specific migration
buddy make:migration <name> # create new migration file
buddy seed # seed database
buddy generate:migrations # generate migrations from model diffs
buddy make:migration create_orders_table
Creates a timestamped migration file in database/migrations/.
When you define or modify a model, generate migrations automatically:
buddy generate:migrations
This diffs model definitions against the current schema and generates the necessary SQL.
The framework includes migrations for all built-in models:
users — id, name, email (unique), password, timestampspersonal_access_tokens — auth tokenspasskeys — WebAuthn credentialspassword_resets — password reset tokensposts — title, content, excerpt, views, status, published_at, author_idpages, categories, tags, commentsauthors — linked to usersproducts, product_variants, product_unitsorders, order_itemscarts, cart_itemscoupons, gift_cards, reviewscustomers, manufacturerspayments, payment_methods, payment_products, payment_transactionssubscriptions, transactionsshipping_methods, shipping_rates, shipping_zonesdelivery_routes, driversjobs, failed_jobs — queue tableserrors, logs, notificationsactivities, requests, websocketsusers.email (unique), users(email, name) (composite)subscribers.email (unique)coupons.code (unique), gift_cards.code (unique)payments.transaction_id (unique)subscriptions.provider_id (unique)storage/framework/models/ or app/Models/buddy generate:migrations to generate SQL diffsbuddy migrate to applymigrate:fresh drops ALL tables — only use in development--seed flag after migrate:fresh seeds the database with factory datastacks-database skill