mirror-nourybot/migrations
2023-10-23 13:48:27 +02:00
..
000001_create_channels_table.down.sql add migrations 2023-09-08 03:55:00 +02:00
000001_create_channels_table.up.sql change name 2023-10-23 13:48:27 +02:00
000002_create_users_table.down.sql add migrations 2023-09-08 03:55:00 +02:00
000002_create_users_table.up.sql change name 2023-10-23 13:48:27 +02:00
000003_create_commands_table.down.sql add migrations 2023-09-08 03:55:00 +02:00
000003_create_commands_table.up.sql add migrations 2023-09-08 03:55:00 +02:00
000004_create_timers_table.down.sql add migrations 2023-09-08 03:55:00 +02:00
000004_create_timers_table.up.sql change name 2023-10-23 13:48:27 +02:00
000005_create_uploads_table.down.sql add uploads model, log downloads/uploads to the database 2023-10-05 23:11:11 +02:00
000005_create_uploads_table.up.sql change name 2023-10-23 13:48:27 +02:00
000006_create_command_logs_table.down.sql implement database logging for used commands 2023-10-10 16:07:35 +02:00
000006_create_command_logs_table.up.sql change name 2023-10-23 13:48:27 +02:00
000007_create_sent_messages_logs_table.down.sql log each outgoing message the bot sends to the database 2023-10-10 16:49:00 +02:00
000007_create_sent_messages_logs_table.up.sql change name 2023-10-23 13:48:27 +02:00
README.md add migrations 2023-09-08 03:55:00 +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