Rephrase, list created files

This commit is contained in:
Marcin K 2019-08-07 22:35:22 +02:00
parent 44b07c5f7b
commit fb771c8dd8
1 changed files with 7 additions and 4 deletions

View File

@ -1,7 +1,7 @@
# Getting started # Getting started
Before you start, you should understand the concept of forward/up and reverse/down database migrations. Before you start, you should understand the concept of forward/up and reverse/down database migrations.
Create new Go project and configure a database for it. Make sure that your database is supported [here](README.md#databases) Configure a database for your application. Make sure that your database driver is supported [here](README.md#databases)
For the purpose of this tutorial let's create PostgreSQL database called `example`. For the purpose of this tutorial let's create PostgreSQL database called `example`.
Our user here is `postgres`, and host is `localhost`. Our user here is `postgres`, and host is `localhost`.
``` ```
@ -19,8 +19,11 @@ Let's create table called `users`:
``` ```
migrate create -ext sql -dir db/migrations create_users_table migrate create -ext sql -dir db/migrations create_users_table
``` ```
If there were no errors, we should have two files available under `db/migrations` folder. Note the `sql` extension that we provided. If there were no errors, we should have two files available under `db/migrations` folder:
In the `.up.sql` file we are going to create table: - 20190805172551_create_users_table.down.sql
- 20190805172551_create_users_table.up.sql
Note the `sql` extension that we provided.
In the `.up.sql` file let's create the table:
``` ```
CREATE TABLE users( CREATE TABLE users(
user_id serial PRIMARY KEY, user_id serial PRIMARY KEY,
@ -29,7 +32,7 @@ CREATE TABLE users(
email VARCHAR (300) UNIQUE NOT NULL email VARCHAR (300) UNIQUE NOT NULL
); );
``` ```
And in the `.down.sql` we are going to delete it: And in the `.down.sql` let's delete it:
``` ```
DROP TABLE users; DROP TABLE users;
``` ```