forked from 3wordchant/capsul-flask
first steps towards multiple hosts -- schema & heartbeat
This commit is contained in:
11
capsulflask/schema_migrations/09_down_introduce_hosts.sql
Normal file
11
capsulflask/schema_migrations/09_down_introduce_hosts.sql
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
DROP TABLE host_operation;
|
||||
|
||||
DROP TABLE operations;
|
||||
|
||||
ALTER TABLE vms DROP COLUMN host;
|
||||
|
||||
DROP TABLE hosts;
|
||||
|
||||
|
||||
UPDATE schemaversion SET version = 8;
|
33
capsulflask/schema_migrations/09_up_introduce_hosts.sql
Normal file
33
capsulflask/schema_migrations/09_up_introduce_hosts.sql
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
CREATE TABLE hosts (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
last_health_check TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
token TEXT NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO hosts (id, token) VALUES ('baikal', 'changeme');
|
||||
|
||||
ALTER TABLE vms
|
||||
ADD COLUMN host TEXT REFERENCES hosts(id) ON DELETE RESTRICT DEFAULT 'baikal';
|
||||
|
||||
CREATE TABLE operations (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
email TEXT REFERENCES accounts(email) ON DELETE RESTRICT,
|
||||
assigned_host TEXT NULL,
|
||||
host_status TEXT NULL,
|
||||
created TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
assigned TIMESTAMP NULL,
|
||||
completed TIMESTAMP NULL,
|
||||
payload TEXT NOT NULL,
|
||||
);
|
||||
|
||||
CREATE TABLE host_operation (
|
||||
host TEXT NOT NULL,
|
||||
operation TEXT NOT NULL,
|
||||
assignment_status TEXT NULL,
|
||||
assignment_status_timestamp TIMESTAMP,
|
||||
PRIMARY KEY (host, operation)
|
||||
);
|
||||
|
||||
UPDATE schemaversion SET version = 9;
|
Reference in New Issue
Block a user