~jae/dn0magik-mc

e892e3fe20506226ba3721d700a333eaab040a8b — Jae Lo Presti (DN0) 1 year, 8 months ago 779698e
Migrations: add migration script & migrations folder
2 files changed, 13 insertions(+), 0 deletions(-)

A src/migrate.sh
A src/migrations/0001-base.py
A src/migrate.sh => src/migrate.sh +1 -0
@@ 0,0 1,1 @@
yoyo apply --database sqlite:///mc.db ./migrations

A src/migrations/0001-base.py => src/migrations/0001-base.py +12 -0
@@ 0,0 1,12 @@
from yoyo import step

steps = [
    step(
        "CREATE TABLE Users (id INT NOT NULL PRIMARY KEY, username VARCHAR(255) NOT NULL, password VARCHAR(255), uuid VARCHAR(255) NOT NULL, registered_on DATETIME NOT NULL)",
        "DROP TABLE Users",
    ),
    step(
        "CREATE TABLE UsernameHistory (id INT NOT NULL PRIMARY KEY, username VARCHAR(255) NOT NULL, changed_on DATETIME NOT NULL, uuid VARCHAR(255) NOT NULL, CONSTRAINT fk_uui FOREIGN KEY (uuid) REFERENCES Users(uuid))",
        "DROP TABLE UsernameHistory",
    ),
]