mirror-nourybot/migrations
2023-03-05 19:44:03 +00:00
..
000001_create_channels_table.down.sql add 'help' column to command model 2023-03-04 00:03:56 +00:00
000001_create_channels_table.up.sql remove noemis channel 2023-03-03 21:15:41 +00:00
000002_create_users_table.down.sql add command category in database and add an command to add the category from 2022-08-15 00:53:41 +02:00
000002_create_users_table.up.sql make level not NOT NULL 2023-03-05 19:44:03 +00:00
000003_create_commands_table.down.sql add 'help' column to command model 2023-03-04 00:03:56 +00:00
000003_create_commands_table.up.sql add help texts to the database migration commands 2023-03-04 03:24:50 +00:00
000004_create_timers_table.down.sql add timer migrations 2022-08-22 02:12:19 +02:00
000004_create_timers_table.up.sql remove old channel 2023-03-03 21:22:38 +00:00
README.md add migration files 2022-08-08 23:58:10 +02:00

Migrations

Tool: golang-migrate

Create Database

$ sudo -u postgres psql
psql (14.3)
Type "help" for help.

postgres=# CREATE DATABASE nourybot;
CREATE DATABASE
postgres=# \c nourybot;
You are now connected to database "nourybot" as user "postgres".
nourybot=# CREATE ROLE username WITH LOGIN PASSWORD 'password';
CREATE ROLE
nourybot=# CREATE EXTENSION IF NOT EXISTS citext;
CREATE EXTENSION
nourybot=# 

Connect to Database

$ psql --host=localhost --dbname=nourybot --username=username
psql (14.3)
Type "help" for help.

nourybot=> 

Apply migrations

$ migrate -path=./migrations -database="postgres://username:password@localhost/nourybot?sslmode=disable" up
$ migrate -path=./migrations -database="postgres://username:password@localhost/nourybot?sslmode=disable" down

Fix Dirty database

$ migrate -path=./migrations -database="postgres://username:password@localhost/nourybot?sslmode=disable" force 1