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: database/postgres/TUTORIAL.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ If there were no errors, we should have two files available under `db/migrations
27
27
Note the `sql` extension that we provided.
28
28
29
29
In the `.up.sql` file let's create the table:
30
-
```
30
+
```sql
31
31
CREATETABLEIF NOT EXISTS users(
32
32
user_id serialPRIMARY KEY,
33
33
username VARCHAR (50) UNIQUE NOT NULL,
@@ -36,7 +36,7 @@ CREATE TABLE IF NOT EXISTS users(
36
36
);
37
37
```
38
38
And in the `.down.sql` let's delete it:
39
-
```
39
+
```sql
40
40
DROPTABLE IF EXISTS users;
41
41
```
42
42
By adding `IF EXISTS/IF NOT EXISTS` we are making migrations idempotent - you can read more about idempotency in [getting started](../../GETTING_STARTED.md#create-migrations)
@@ -79,7 +79,7 @@ Again, it should create for us two migrations files:
79
79
In Postgres, when we want our queries to be done in a transaction, we need to wrap it with `BEGIN` and `COMMIT` commands.
80
80
In our example, we are going to add a column to our database that can only accept enumerable values or NULL.
0 commit comments