You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/docs/content/guides/deployment/database-migrations.mdx
+58-12Lines changed: 58 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -135,7 +135,11 @@ supabase migration up
135
135
136
136
Finally, you should see the `department` column added to your `employees` table in the local Dashboard.
137
137
138
-
View the [complete code](https://github.com/supabase/supabase/tree/master/examples/database/employees) for this example.
138
+
<Admonitiontype="info">
139
+
140
+
View the [complete code](https://github.com/supabase/supabase/tree/master/examples/database/employees) for this example on GitHub.
141
+
142
+
</Admonition>
139
143
140
144
### Seeding data
141
145
@@ -175,7 +179,7 @@ values
175
179
176
180
<StepHikeCompact.Code>
177
181
178
-
```bash
182
+
```bash Terminal
179
183
supabase db reset
180
184
```
181
185
@@ -190,25 +194,67 @@ You should now see the `employees` table, along with your seed data in the Dashb
190
194
191
195
This workflow is great if you know SQL and are comfortable creating tables and columns. If not, you can still use the Dashboard to create tables and columns, and then use the CLI to diff your changes and create migrations.
192
196
193
-
Create a new table called `cities`, with columns `id`, `name` and `population`. To see the corresponding SQL for this, you can use the `supabase db diff --schema public` command. This will show you the SQL that will be run to create the table and columns. The output of `supabase db diff` will look something like this:
197
+
<StepHikeCompact>
198
+
199
+
<StepHikeCompact.Stepstep={1}>
200
+
<StepHikeCompact.Detailstitle="Create your table from the Dashboard">
201
+
Create a new table called `cities`, with columns `id`, `name` and `population`.
194
202
203
+
Then generate a [schema diff](/docs/reference/cli/supabase-db-diff).
204
+
</StepHikeCompact.Details>
205
+
206
+
<StepHikeCompact.Code>
207
+
208
+
```bash Terminal
209
+
supabase db diff -f create_cities_table
195
210
```
196
-
Diffing schemas: public
197
-
Finished supabase db diff on branch main.
198
211
212
+
</StepHikeCompact.Code>
213
+
214
+
</StepHikeCompact.Step>
215
+
</StepHikeCompact>
216
+
217
+
<StepHikeCompact>
218
+
219
+
<StepHikeCompact.Stepstep={2}>
220
+
<StepHikeCompact.Detailstitle="Add schema diff as a migration">
221
+
A new migration file is created for you.
222
+
223
+
Alternately, you can copy the table definitions directly from the Table Editor.
0 commit comments