mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add migration files
This commit is contained in:
parent
6fbe68a0a4
commit
53481c274e
1
migrations/000001_create_channels_table.down.sql
Normal file
1
migrations/000001_create_channels_table.down.sql
Normal file
|
@ -0,0 +1 @@
|
|||
DROP TABLE IF EXISTS channels;
|
7
migrations/000001_create_channels_table.up.sql
Normal file
7
migrations/000001_create_channels_table.up.sql
Normal file
|
@ -0,0 +1,7 @@
|
|||
CREATE TABLE IF NOT EXISTS channels (
|
||||
id bigserial PRIMARY KEY,
|
||||
joined_at timestamp(0) with time zone NOT NULL DEFAULT NOW(),
|
||||
login text NOT NULL,
|
||||
twitchid text NOT NULL,
|
||||
announce BOOLEAN NOT NULL
|
||||
);
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
Tool: [golang-migrate](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate)
|
||||
|
||||
```
|
||||
## Create Database
|
||||
```sql
|
||||
$ sudo -u postgres psql
|
||||
psql (14.3)
|
||||
Type "help" for help.
|
||||
|
@ -18,10 +19,25 @@ CREATE EXTENSION
|
|||
nourybot=#
|
||||
```
|
||||
|
||||
```
|
||||
## Connect to Database
|
||||
```sh
|
||||
$ psql --host=localhost --dbname=nourybot --username=username
|
||||
psql (14.3)
|
||||
Type "help" for help.
|
||||
|
||||
nourybot=>
|
||||
```
|
||||
|
||||
## Apply migrations
|
||||
```sh
|
||||
$ migrate -path=./migrations -database="postgres://username:password@localhost/nourybot?sslmode=disable" up
|
||||
```
|
||||
|
||||
```sh
|
||||
$ migrate -path=./migrations -database="postgres://username:password@localhost/nourybot?sslmode=disable" down
|
||||
```
|
||||
|
||||
## Fix Dirty database
|
||||
```sh
|
||||
$ migrate -path=./migrations -database="postgres://username:password@localhost/nourybot?sslmode=disable" force 1
|
||||
```
|
Loading…
Reference in a new issue