The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(docs): fix tab bar overlapping code blocks (#49775)
Anthony Lio55385adad547
diff --git a/apps/docs/content/guides/local-development/declarative-database-schemas.mdx b/apps/docs/content/guides/local-development/declarative-database-schemas.mdxindex 513d129fd51..404648f57b0 100644--- a/apps/docs/content/guides/local-development/declarative-database-schemas.mdx+++ b/apps/docs/content/guides/local-development/declarative-database-schemas.mdx@@ -28,8 +28,6 @@ Schema migrations are SQL statements written in Data Definition Language. They a<StepHikeCompact.Code>-<$CodeTabs>-```sql name=supabase/schemas/employees.sqlcreate table "employees" ("id" integer not null,@@ -37,8 +35,6 @@ create table "employees" ();```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -53,14 +49,10 @@ create table "employees" (<StepHikeCompact.Code>-<$CodeTabs>-```bash name=Terminalsupabase db diff -f create_employees_table```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -75,15 +67,11 @@ supabase db diff -f create_employees_table<StepHikeCompact.Code>-<$CodeTabs>-```bash name=Terminalsupabase startsupabase migration up```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -106,8 +94,6 @@ With declarative schemas, the files in `supabase/schemas/` are the source of tru<StepHikeCompact.Code>-<$CodeTabs>-```sql name=supabase/schemas/employees.sqlcreate table "employees" ("id" integer not null,@@ -116,8 +102,6 @@ create table "employees" ();```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -138,14 +122,10 @@ Some entities like views and enums expect columns to be declared in a specific o<StepHikeCompact.Code>-<$CodeTabs>-```bash name=Terminalsupabase db diff -f add_age```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -160,14 +140,10 @@ supabase db diff -f add_age<StepHikeCompact.Code>-<$CodeTabs>-```sql name=supabase/migrations/<timestamp>_add_age.sqlalter table "public"."employees" add column "age" smallint not null;```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -181,14 +157,10 @@ alter table "public"."employees" add column "age" smallint not null;<StepHikeCompact.Code>-<$CodeTabs>-```bash name=Terminalsupabase migration up```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -205,14 +177,10 @@ supabase migration up<StepHikeCompact.Code>-<$CodeTabs>-```bash name=Terminalsupabase login```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -224,14 +192,10 @@ supabase login<StepHikeCompact.Code>-<$CodeTabs>-```bash name=Terminalsupabase link```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -243,14 +207,10 @@ supabase link<StepHikeCompact.Code>-<$CodeTabs>-```bash name=Terminalsupabase db push```-</$CodeTabs>-</StepHikeCompact.Code></StepHikeCompact.Step>@@ -260,8 +220,6 @@ supabase db pushAs your database schema evolves, you will probably start using more advanced entities like views and functions. These entities are notoriously verbose to manage using plain migrations because the entire body must be recreated whenever there is a change. Using declarative schema, you can now edit them in-place so it’s much easier to review.-<$CodeTabs>-```sql name=supabase/schemas/employees.sqlcreate table "employees" ("id" integer not null,@@ -281,8 +239,6 @@ AS $$$$;```-</$CodeTabs>-Your schema files are run in lexicographic order by default. The order is important when you have foreign keys between multiple tables as the parent table must be created first. For example, your `supabase` directory may end up with the following structure.```bash@@ -299,8 +255,6 @@ Your schema files are run in lexicographic order by default. The order is importFor small projects with only a few tables, the default schema order may be sufficient. However, as your project grows, you might need more control over the order in which schemas are applied. To specify a custom order for applying the schemas, you can declare them explicitly in `config.toml`. Any glob patterns will evaluated, deduplicated, and sorted in lexicographic order. For example, the following pattern ensures `employees.sql` is always executed first.-<$CodeTabs>-```toml name=supabase/config.toml[db.migrations]schema_paths = [@@ -309,34 +263,24 @@ schema_paths = []```-</$CodeTabs>-### Pulling in your production schemaTo set up declarative schemas on a existing project, you can pull in your production schema by running:-<$CodeTabs>-```bash name=Terminalsupabase db dump > supabase/schemas/prod.sql```-</$CodeTabs>-From 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 changeDuring 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.-<$CodeTabs>-```bash name=Terminalsupabase db reset --version 20241005112233```-</$CodeTabs>-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.