Skip to content

Add Schema Migration Support #34

@andrewlalis

Description

@andrewlalis

Currently, it's not very easy to update the bot's SQL schema which is used for strictly-typed relational data. This should be made simpler so that newer releases can update the schema without having to manually open a command-line connection to the database.

I have a few ideas for how this can be done:

  1. SQL migrations are performed by sending an SQL code block or SQL file into a Discord channel, so that the bot can read the migration script from that.
  2. Add migrations as SQL files to the bot's resources, so that on startup the bot will look for any migrations to perform.

I'm leaning towards the second option, but in both cases this involves first making a migration table in the database to ensure that we don't try to run a migration that has already been run.

CREATE TABLE migration (
    name VARCHAR(255) PRIMARY KEY,
    created_at TIMESTAMP(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
    script_hash VARCHAR(1024) NOT NULL,
    performed_at TIMESTAMP(0),
    performed_by BIGINT,
    successful BOOLEAN
);

Metadata

Metadata

Assignees

Labels

enhancementImprovement of an already existing feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions