diff options
author | Niall Sheridan <nsheridan@gmail.com> | 2018-08-05 23:00:58 +0100 |
---|---|---|
committer | Niall Sheridan <nsheridan@gmail.com> | 2018-08-07 15:43:39 +0100 |
commit | d836a4496de7b24a9d3317e274800d35053a04f6 (patch) | |
tree | df290dee5a247b70126a62ec367d1642c44c5113 /server/store/migrations/sqlite3 | |
parent | b7b3e5cfad53732a379b3784ec2c3b72577ab665 (diff) |
Manage db schema with rubenv/sql-migrate
It's currently hard to make changes to the database schema. Use sql-migrate to make incremental changes.
Stop hard-coding the database name (the default is still "certs" for backward-compatibility)
The `automigrate()` function will automatically run pending migrations.
Use a different migration directory per database driver. This carries a cost of duplication, but is easier than creating migrations which will cleanly execute in both SQLite and MySQL.
Migrations are shipped using the packr utility.
Diffstat (limited to 'server/store/migrations/sqlite3')
-rw-r--r-- | server/store/migrations/sqlite3/20180626224600_create_issued_certs.sql | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/server/store/migrations/sqlite3/20180626224600_create_issued_certs.sql b/server/store/migrations/sqlite3/20180626224600_create_issued_certs.sql new file mode 100644 index 0000000..c5b80e0 --- /dev/null +++ b/server/store/migrations/sqlite3/20180626224600_create_issued_certs.sql @@ -0,0 +1,15 @@ +-- +migrate Up +CREATE TABLE IF NOT EXISTS `issued_certs` ( + `key_id` varchar(255) NOT NULL, + `principals` varchar(255) DEFAULT "[]", + `created_at` datetime DEFAULT '1970-01-01 00:00:01', + `expires_at` datetime DEFAULT '1970-01-01 00:00:01', + `revoked` tinyint(1) DEFAULT 0, + `raw_key` text, + PRIMARY KEY (`key_id`) +); +CREATE INDEX `idx_expires_at` ON `issued_certs` (`expires_at`); +CREATE INDEX `idx_revoked_expires_at` ON `issued_certs` (`revoked`, `expires_at`); + +-- +migrate Down +DROP TABLE `issued_certs`; |