The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: document how to rollback declarative schema (#34469)
Han Qiao73e885b513ac
diff --git a/apps/docs/content/guides/local-development/declarative-database-schemas.mdx b/apps/docs/content/guides/local-development/declarative-database-schemas.mdxindex 021359f1b5a..663704b7b5d 100644--- a/apps/docs/content/guides/local-development/declarative-database-schemas.mdx+++ b/apps/docs/content/guides/local-development/declarative-database-schemas.mdx@@ -236,6 +236,24 @@ supabase db dump > supabase/schemas/prod.sqlFrom there, you can start breaking down your schema into smaller files and generate migrations. You can do this all at once, or incrementally as you make changes to your schema.+### Rolling back a schema change++During development, you may want to rollback a migration to keep your new schema changes in a single migration file. This can be done by resetting your local database to a previous version.++```bash Terminal+supabase db reset --version 20241005112233+```++After a reset, you can [edit the schema](#updating-your-schema) and regenerate a new migration file. Note that you should not reset a version that's already deployed to production.++If you need to rollback a migration that's already deployed, you should first revert changes to the schema files. Then you can generate a new migration file containing the down migration. This ensures your production migrations are always rolling forward.++<Admonition type="danger">++SQL statements generated in a down migration are usually destructive. You must review them carefully to avoid unintentional data loss.++</Admonition>+## Known caveatsThe `migra` diff tool used for generating schema diff is capable of tracking most database changes. However, there are edge cases where it can fail.