simplex/migrations.moon
2018-04-24 19:44:46 -07:00

46 lines
1.3 KiB
Plaintext

import create_table, types, create_index, add_column from require "lapis.db.schema"
import make_migrations, autoload from require "locator"
import settings from autoload "utility"
make_migrations {
[1524503851]: =>
create_table "tasks", {
{"id", types.serial primary_key: true}
{"user_id", types.foreign_key}
{"content", types.text}
{"done", types.boolean default: false}
{"created_at", types.time}
{"updated_at", types.time}
}
create_table "api_keys", {
{"user_id", types.foreign_key}
{"key", types.varchar unique: true}
{"created_at", types.time}
{"updated_at", types.time}
}
create_index "api_keys", "user_id"
create_index "api_keys", "key"
create_index "tasks", "id"
create_index "tasks", "user_id"
create_index "tasks", "user_id", "done"
-- botched migration
[1524517478]: =>
settings["simplex.key-increment"] = 0
[1524517479]: =>
settings.set "simplex.key-increment", 0
[1524605427]: =>
add_column "api_keys", "id", types.serial primary_key: true
[1524607145]: =>
settings.set "simplex.key-increment", 100 -- I had been accidentally deleting this key over and over again
-- technically there should be a migration here to wipe out the api_keys table
-- due to a strange bug with how adding an id to api_keys works (I think)
}