Use new in-built database migrations in API

This commit is contained in:
Joshua Boniface 2023-09-01 15:42:23 -04:00
parent 0e5cb688dc
commit b4079cae88
4 changed files with 5 additions and 16 deletions

View File

@ -1,11 +0,0 @@
CREATE TABLE system_template (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, vcpu_count INT NOT NULL, vram_mb INT NOT NULL, serial BOOL NOT NULL, vnc BOOL NOT NULL, vnc_bind TEXT, node_limit TEXT, node_selector TEXT, node_autostart BOOL NOT NULL);
CREATE TABLE network_template (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, mac_template TEXT);
CREATE TABLE network (id SERIAL PRIMARY KEY, network_template INT REFERENCES network_template(id), vni INT NOT NULL);
CREATE TABLE storage_template (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE);
CREATE TABLE storage (id SERIAL PRIMARY KEY, storage_template INT REFERENCES storage_template(id), pool TEXT NOT NULL, disk_id TEXT NOT NULL, source_volume TEXT, disk_size_gb INT, mountpoint TEXT, filesystem TEXT, filesystem_args TEXT);
CREATE TABLE userdata (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, userdata TEXT NOT NULL);
CREATE TABLE script (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, script TEXT NOT NULL);
CREATE TABLE profile (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, system_template INT REFERENCES system_template(id), network_template INT REFERENCES network_template(id), storage_template INT REFERENCES storage_template(id), userdata INT REFERENCES userdata(id), script INT REFERENCES script(id), arguments text);
INSERT INTO userdata (name, userdata) VALUES ('empty', '');
INSERT INTO script (name, script) VALUES ('empty', '');

View File

@ -89,8 +89,5 @@
- name: import DNS database schema - name: import DNS database schema
command: "psql -U {{ pvc_dns_database_user }} -f /etc/postgresql/powerdns-schema.sql {{ pvc_dns_database_name }}" command: "psql -U {{ pvc_dns_database_user }} -f /etc/postgresql/powerdns-schema.sql {{ pvc_dns_database_name }}"
- name: import Provisioner database schema
command: "psql -U {{ pvc_prov_database_user }} -f /etc/postgresql/provisioner-schema.sql {{ pvc_prov_database_name }}"
become: yes become: yes
become_user: postgres become_user: postgres

View File

@ -69,7 +69,6 @@
mode: 0640 mode: 0640
with_items: with_items:
- { src: "patroni/powerdns-schema.sql", dest: "/etc/postgresql/powerdns-schema.sql" } - { src: "patroni/powerdns-schema.sql", dest: "/etc/postgresql/powerdns-schema.sql" }
- { src: "patroni/provisioner-schema.sql", dest: "/etc/postgresql/provisioner-schema.sql" }
- include: patroni/bootstrap.yml - include: patroni/bootstrap.yml
run_once: yes run_once: yes

View File

@ -46,9 +46,13 @@
- pdns.service - pdns.service
- dnsmasq.service - dnsmasq.service
- name: prepare Patroni database migrations (on all hosts)
command: /usr/share/pvc/pvc-api-db-init
when: bootstrap is defined and bootstrap and is_coordinator
- include: pvc/bootstrap.yml - include: pvc/bootstrap.yml
when: bootstrap is defined and bootstrap
run_once: yes run_once: yes
when: bootstrap is defined and bootstrap and is_coordinator
- name: enable daemon services but don't start them - name: enable daemon services but don't start them
service: service: