Skip to content

Commit b39ee92

Browse files
authored
Merge pull request #999 from tobyscott25/patch-1
Add syntax highlighting to Postgres example
2 parents f375aeb + 12968a7 commit b39ee92

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

database/postgres/TUTORIAL.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ If there were no errors, we should have two files available under `db/migrations
2727
Note the `sql` extension that we provided.
2828

2929
In the `.up.sql` file let's create the table:
30-
```
30+
```sql
3131
CREATE TABLE IF NOT EXISTS users(
3232
user_id serial PRIMARY KEY,
3333
username VARCHAR (50) UNIQUE NOT NULL,
@@ -36,7 +36,7 @@ CREATE TABLE IF NOT EXISTS users(
3636
);
3737
```
3838
And in the `.down.sql` let's delete it:
39-
```
39+
```sql
4040
DROP TABLE IF EXISTS users;
4141
```
4242
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:
7979
In Postgres, when we want our queries to be done in a transaction, we need to wrap it with `BEGIN` and `COMMIT` commands.
8080
In our example, we are going to add a column to our database that can only accept enumerable values or NULL.
8181
Migration up:
82-
```
82+
```sql
8383
BEGIN;
8484

8585
CREATE TYPE enum_mood AS ENUM (
@@ -92,7 +92,7 @@ ALTER TABLE users ADD COLUMN mood enum_mood;
9292
COMMIT;
9393
```
9494
Migration down:
95-
```
95+
```sql
9696
BEGIN;
9797

9898
ALTER TABLE users DROP COLUMN mood;
@@ -124,7 +124,7 @@ Indexes:
124124

125125
## Optional: Run migrations within your Go app
126126
Here is a very simple app running migrations for the above configuration:
127-
```
127+
```go
128128
import (
129129
"log"
130130

0 commit comments

Comments
 (0)