forked from 3wordchant/capsul-flask
Merge branch 'master' into multiple-hosts
Conflicts: capsulflask/console.py capsulflask/db.py capsulflask/shared.py capsulflask/virt_model.py
This commit is contained in:
5
capsulflask/schema_migrations/09_down_email_case.sql
Normal file
5
capsulflask/schema_migrations/09_down_email_case.sql
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
ALTER TABLE accounts DROP COLUMN lower_case_email;
|
||||
ALTER TABLE accounts DROP COLUMN ever_logged_in;
|
||||
|
||||
UPDATE schemaversion SET version = 8;
|
10
capsulflask/schema_migrations/09_up_email_case.sql
Normal file
10
capsulflask/schema_migrations/09_up_email_case.sql
Normal file
@ -0,0 +1,10 @@
|
||||
ALTER TABLE accounts
|
||||
ADD COLUMN lower_case_email TEXT NULL;
|
||||
|
||||
ALTER TABLE accounts
|
||||
ADD COLUMN ever_logged_in BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
|
||||
UPDATE accounts set lower_case_email = LOWER(accounts.email);
|
||||
UPDATE accounts set ever_logged_in = TRUE;
|
||||
|
||||
UPDATE schemaversion SET version = 9;
|
@ -0,0 +1,3 @@
|
||||
DELETE FROM os_images WHERE id = 'guixsystem120';
|
||||
|
||||
UPDATE schemaversion SET version = 9;
|
4
capsulflask/schema_migrations/10_up_guixsystem1.2.0.sql
Normal file
4
capsulflask/schema_migrations/10_up_guixsystem1.2.0.sql
Normal file
@ -0,0 +1,4 @@
|
||||
INSERT INTO os_images (id, template_image_file_name, description, deprecated)
|
||||
VALUES ('guixsystem120', 'guixsystem/1.2.0/root.img.qcow2', 'Guix System 1.2.0', FALSE);
|
||||
|
||||
UPDATE schemaversion SET version = 10;
|
5
capsulflask/schema_migrations/11_down_alpine_3.13.sql
Normal file
5
capsulflask/schema_migrations/11_down_alpine_3.13.sql
Normal file
@ -0,0 +1,5 @@
|
||||
DELETE FROM os_images WHERE id = 'alpine313';
|
||||
|
||||
UPDATE os_images SET deprecated = FALSE WHERE id = 'alpine312';
|
||||
|
||||
UPDATE schemaversion SET version = 10;
|
6
capsulflask/schema_migrations/11_up_alpine_3.13.sql
Normal file
6
capsulflask/schema_migrations/11_up_alpine_3.13.sql
Normal file
@ -0,0 +1,6 @@
|
||||
INSERT INTO os_images (id, template_image_file_name, description, deprecated)
|
||||
VALUES ('alpine313', 'alpine/3.13/root.img.qcow2', 'Alpine Linux 3.13', FALSE);
|
||||
|
||||
UPDATE os_images SET deprecated = TRUE WHERE id = 'alpine312';
|
||||
|
||||
UPDATE schemaversion SET version = 11;
|
7
capsulflask/schema_migrations/12_down_ssh_host_keys.sql
Normal file
7
capsulflask/schema_migrations/12_down_ssh_host_keys.sql
Normal file
@ -0,0 +1,7 @@
|
||||
|
||||
|
||||
DROP TABLE vm_ssh_host_key;
|
||||
|
||||
ALTER TABLE vm_ssh_authorized_key RENAME TO vm_ssh_public_key;
|
||||
|
||||
UPDATE schemaversion SET version = 11;
|
14
capsulflask/schema_migrations/12_up_ssh_host_keys.sql
Normal file
14
capsulflask/schema_migrations/12_up_ssh_host_keys.sql
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
CREATE TABLE vm_ssh_host_key (
|
||||
email TEXT NOT NULL,
|
||||
vm_id TEXT NOT NULL,
|
||||
key_type TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
sha256 TEXT NOT NULL,
|
||||
FOREIGN KEY (email, vm_id) REFERENCES vms(email, id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (email, vm_id, key_type)
|
||||
);
|
||||
|
||||
ALTER TABLE vm_ssh_public_key RENAME TO vm_ssh_authorized_key;
|
||||
|
||||
UPDATE schemaversion SET version = 12;
|
11
capsulflask/schema_migrations/13_down_introduce_hosts.sql
Normal file
11
capsulflask/schema_migrations/13_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 = 12;
|
32
capsulflask/schema_migrations/13_up_introduce_hosts.sql
Normal file
32
capsulflask/schema_migrations/13_up_introduce_hosts.sql
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
CREATE TABLE hosts (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
last_health_check TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
https_url TEXT NOT NULL,
|
||||
token TEXT NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO hosts (id, https_url, token) VALUES ('baikal', 'http://localhost:5000', 'changeme');
|
||||
|
||||
ALTER TABLE vms
|
||||
ADD COLUMN host TEXT REFERENCES hosts(id) ON DELETE RESTRICT DEFAULT 'baikal';
|
||||
|
||||
CREATE TABLE operations (
|
||||
id SERIAL PRIMARY KEY ,
|
||||
email TEXT REFERENCES accounts(email) ON DELETE RESTRICT,
|
||||
created TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
payload TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE host_operation (
|
||||
host TEXT NOT NULL REFERENCES hosts(id) ON DELETE RESTRICT,
|
||||
operation INTEGER NOT NULL REFERENCES operations(id) ON DELETE RESTRICT,
|
||||
assignment_status TEXT NULL,
|
||||
assigned TIMESTAMP NULL,
|
||||
completed TIMESTAMP NULL,
|
||||
results TEXT NULL,
|
||||
PRIMARY KEY (host, operation)
|
||||
);
|
||||
|
||||
UPDATE schemaversion SET version = 13;
|
Reference in New Issue
Block a user