SHARE
TWEET

Untitled

a guest Jul 18th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PRAGMA foreign_keys=OFF;
  2. BEGIN TRANSACTION;
  3. CREATE TABLE schema (
  4.     id         INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  5.     version    INTEGER NOT NULL,
  6.     updated_at DATETIME NOT NULL,
  7.     UNIQUE (version)
  8. );
  9. INSERT INTO schema VALUES(1,14,1550820074);
  10. CREATE TABLE "containers" (
  11.     id INTEGER primary key AUTOINCREMENT NOT NULL,
  12.     node_id INTEGER NOT NULL,
  13.     name TEXT NOT NULL,
  14.     architecture INTEGER NOT NULL,
  15.     type INTEGER NOT NULL,
  16.     ephemeral INTEGER NOT NULL DEFAULT 0,
  17.     creation_date DATETIME NOT NULL DEFAULT 0,
  18.     stateful INTEGER NOT NULL DEFAULT 0,
  19.     last_use_date DATETIME,
  20.     description TEXT,
  21.     project_id INTEGER NOT NULL,
  22.     expiry_date DATETIME,
  23.     UNIQUE (project_id, name),
  24.     FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE,
  25.     FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE
  26. );
  27. CREATE TABLE "images" (
  28.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  29.     fingerprint TEXT NOT NULL,
  30.     filename TEXT NOT NULL,
  31.     size INTEGER NOT NULL,
  32.     public INTEGER NOT NULL DEFAULT 0,
  33.     architecture INTEGER NOT NULL,
  34.     creation_date DATETIME,
  35.     expiry_date DATETIME,
  36.     upload_date DATETIME NOT NULL,
  37.     cached INTEGER NOT NULL DEFAULT 0,
  38.     last_use_date DATETIME,
  39.     auto_update INTEGER NOT NULL DEFAULT 0,
  40.     project_id INTEGER NOT NULL,
  41.     UNIQUE (project_id, fingerprint),
  42.     FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE
  43. );
  44. CREATE TABLE "images_aliases" (
  45.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  46.     name TEXT NOT NULL,
  47.     image_id INTEGER NOT NULL,
  48.     description TEXT,
  49.     project_id INTEGER NOT NULL,
  50.     UNIQUE (project_id, name),
  51.     FOREIGN KEY (image_id) REFERENCES images (id) ON DELETE CASCADE,
  52.     FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE
  53. );
  54. CREATE TABLE "operations" (
  55.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  56.     uuid TEXT NOT NULL,
  57.     node_id TEXT NOT NULL,
  58.     type INTEGER NOT NULL DEFAULT 0,
  59.     project_id INTEGER,
  60.     UNIQUE (uuid),
  61.     FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE,
  62.     FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE
  63. );
  64. CREATE TABLE "profiles" (
  65.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  66.     name TEXT NOT NULL,
  67.     description TEXT,
  68.     project_id INTEGER NOT NULL,
  69.     UNIQUE (project_id, name),
  70.     FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE
  71. );
  72. CREATE TABLE "storage_volumes" (
  73.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  74.     name TEXT NOT NULL,
  75.     storage_pool_id INTEGER NOT NULL,
  76.     node_id INTEGER NOT NULL,
  77.     type INTEGER NOT NULL,
  78.     description TEXT,
  79.     snapshot INTEGER NOT NULL DEFAULT 0,
  80.     project_id INTEGER NOT NULL,
  81.     UNIQUE (storage_pool_id, node_id, project_id, name, type),
  82.     FOREIGN KEY (storage_pool_id) REFERENCES storage_pools (id) ON DELETE CASCADE,
  83.     FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE,
  84.     FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE
  85. );
  86. CREATE TABLE certificates (
  87.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  88.     fingerprint TEXT NOT NULL,
  89.     type INTEGER NOT NULL,
  90.     name TEXT NOT NULL,
  91.     certificate TEXT NOT NULL,
  92.     UNIQUE (fingerprint)
  93. );
  94. CREATE TABLE config (
  95.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  96.     key TEXT NOT NULL,
  97.     value TEXT,
  98.     UNIQUE (key)
  99. );
  100. CREATE TABLE containers_backups (
  101.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  102.     container_id INTEGER NOT NULL,
  103.     name VARCHAR(255) NOT NULL,
  104.     creation_date DATETIME,
  105.     expiry_date DATETIME,
  106.     container_only INTEGER NOT NULL default 0,
  107.     optimized_storage INTEGER NOT NULL default 0,
  108.     FOREIGN KEY (container_id) REFERENCES containers (id) ON DELETE CASCADE,
  109.     UNIQUE (container_id, name)
  110. );
  111. CREATE TABLE containers_config (
  112.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  113.     container_id INTEGER NOT NULL,
  114.     key TEXT NOT NULL,
  115.     value TEXT,
  116.     FOREIGN KEY (container_id) REFERENCES containers (id) ON DELETE CASCADE,
  117.     UNIQUE (container_id, key)
  118. );
  119. CREATE TABLE containers_devices (
  120.     id INTEGER primary key AUTOINCREMENT NOT NULL,
  121.     container_id INTEGER NOT NULL,
  122.     name TEXT NOT NULL,
  123.     type INTEGER NOT NULL default 0,
  124.     FOREIGN KEY (container_id) REFERENCES containers (id) ON DELETE CASCADE,
  125.     UNIQUE (container_id, name)
  126. );
  127. CREATE TABLE containers_devices_config (
  128.     id INTEGER primary key AUTOINCREMENT NOT NULL,
  129.     container_device_id INTEGER NOT NULL,
  130.     key TEXT NOT NULL,
  131.     value TEXT,
  132.     FOREIGN KEY (container_device_id) REFERENCES containers_devices (id) ON DELETE CASCADE,
  133.     UNIQUE (container_device_id, key)
  134. );
  135. CREATE TABLE containers_profiles (
  136.     id INTEGER primary key AUTOINCREMENT NOT NULL,
  137.     container_id INTEGER NOT NULL,
  138.     profile_id INTEGER NOT NULL,
  139.     apply_order INTEGER NOT NULL default 0,
  140.     UNIQUE (container_id, profile_id),
  141.     FOREIGN KEY (container_id) REFERENCES containers(id) ON DELETE CASCADE,
  142.     FOREIGN KEY (profile_id) REFERENCES profiles(id) ON DELETE CASCADE
  143. );
  144. CREATE TABLE images_nodes (
  145.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  146.     image_id INTEGER NOT NULL,
  147.     node_id INTEGER NOT NULL,
  148.     UNIQUE (image_id, node_id),
  149.     FOREIGN KEY (image_id) REFERENCES images (id) ON DELETE CASCADE,
  150.     FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
  151. );
  152. CREATE TABLE images_properties (
  153.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  154.     image_id INTEGER NOT NULL,
  155.     type INTEGER NOT NULL,
  156.     key TEXT NOT NULL,
  157.     value TEXT,
  158.     FOREIGN KEY (image_id) REFERENCES images (id) ON DELETE CASCADE
  159. );
  160. CREATE TABLE images_source (
  161.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  162.     image_id INTEGER NOT NULL,
  163.     server TEXT NOT NULL,
  164.     protocol INTEGER NOT NULL,
  165.     certificate TEXT NOT NULL,
  166.     alias TEXT NOT NULL,
  167.     FOREIGN KEY (image_id) REFERENCES images (id) ON DELETE CASCADE
  168. );
  169. CREATE TABLE networks (
  170.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  171.     name TEXT NOT NULL,
  172.     description TEXT,
  173.     state INTEGER NOT NULL DEFAULT 0,
  174.     UNIQUE (name)
  175. );
  176. CREATE TABLE networks_config (
  177.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  178.     network_id INTEGER NOT NULL,
  179.     node_id INTEGER,
  180.     key TEXT NOT NULL,
  181.     value TEXT,
  182.     UNIQUE (network_id, node_id, key),
  183.     FOREIGN KEY (network_id) REFERENCES networks (id) ON DELETE CASCADE,
  184.     FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
  185. );
  186. CREATE TABLE networks_nodes (
  187.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  188.     network_id INTEGER NOT NULL,
  189.     node_id INTEGER NOT NULL,
  190.     UNIQUE (network_id, node_id),
  191.     FOREIGN KEY (network_id) REFERENCES networks (id) ON DELETE CASCADE,
  192.     FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
  193. );
  194. CREATE TABLE nodes (
  195.     id INTEGER PRIMARY KEY,
  196.     name TEXT NOT NULL,
  197.     description TEXT DEFAULT '',
  198.     address TEXT NOT NULL,
  199.     schema INTEGER NOT NULL,
  200.     api_extensions INTEGER NOT NULL,
  201.     heartbeat DATETIME DEFAULT CURRENT_TIMESTAMP,
  202.     pending INTEGER NOT NULL DEFAULT 0,
  203.     UNIQUE (name),
  204.     UNIQUE (address)
  205. );
  206. CREATE TABLE profiles_config (
  207.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  208.     profile_id INTEGER NOT NULL,
  209.     key TEXT NOT NULL,
  210.     value TEXT,
  211.     UNIQUE (profile_id, key),
  212.     FOREIGN KEY (profile_id) REFERENCES profiles(id) ON DELETE CASCADE
  213. );
  214. CREATE TABLE profiles_devices (
  215.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  216.     profile_id INTEGER NOT NULL,
  217.     name TEXT NOT NULL,
  218.     type INTEGER NOT NULL default 0,
  219.     UNIQUE (profile_id, name),
  220.     FOREIGN KEY (profile_id) REFERENCES profiles (id) ON DELETE CASCADE
  221. );
  222. CREATE TABLE profiles_devices_config (
  223.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  224.     profile_device_id INTEGER NOT NULL,
  225.     key TEXT NOT NULL,
  226.     value TEXT,
  227.     UNIQUE (profile_device_id, key),
  228.     FOREIGN KEY (profile_device_id) REFERENCES profiles_devices (id) ON DELETE CASCADE
  229. );
  230. CREATE TABLE projects (
  231.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  232.     name TEXT NOT NULL,
  233.     description TEXT,
  234.     UNIQUE (name)
  235. );
  236. CREATE TABLE projects_config (
  237.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  238.     project_id INTEGER NOT NULL,
  239.     key TEXT NOT NULL,
  240.     value TEXT,
  241.     FOREIGN KEY (project_id) REFERENCES projects (id) ON DELETE CASCADE,
  242.     UNIQUE (project_id, key)
  243. );
  244. CREATE TABLE storage_pools (
  245.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  246.     name TEXT NOT NULL,
  247.     driver TEXT NOT NULL,
  248.     description TEXT,
  249.     state INTEGER NOT NULL DEFAULT 0,
  250.     UNIQUE (name)
  251. );
  252. CREATE TABLE storage_pools_config (
  253.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  254.     storage_pool_id INTEGER NOT NULL,
  255.     node_id INTEGER,
  256.     key TEXT NOT NULL,
  257.     value TEXT,
  258.     UNIQUE (storage_pool_id, node_id, key),
  259.     FOREIGN KEY (storage_pool_id) REFERENCES storage_pools (id) ON DELETE CASCADE,
  260.     FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
  261. );
  262. CREATE TABLE storage_pools_nodes (
  263.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  264.     storage_pool_id INTEGER NOT NULL,
  265.     node_id INTEGER NOT NULL,
  266.     UNIQUE (storage_pool_id, node_id),
  267.     FOREIGN KEY (storage_pool_id) REFERENCES storage_pools (id) ON DELETE CASCADE,
  268.     FOREIGN KEY (node_id) REFERENCES nodes (id) ON DELETE CASCADE
  269. );
  270. CREATE TABLE storage_volumes_config (
  271.     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  272.     storage_volume_id INTEGER NOT NULL,
  273.     key TEXT NOT NULL,
  274.     value TEXT,
  275.     UNIQUE (storage_volume_id, key),
  276.     FOREIGN KEY (storage_volume_id) REFERENCES storage_volumes (id) ON DELETE CASCADE
  277. );
  278. COMMIT;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top