'use strict'; exports.up = function(knex, Promise) { return Promise.all([ knex.schema.createTable("images", (table) => { table.increments("id"); table.integer("userId").notNullable(); // user that added it table.uuid("fileId").notNullable(); table.text("name"); table.text("description"); table.enum("sourceType", ["local", "http", "upload"]).notNullable(); table.text("source"); // URL, path, etc. table.enum("imageType", ["disk", "tarball"]).notNullable(); // eg. tarballs for OpenVZ table.boolean("public").notNullable(); // whether the image should be visible to everybody, or just its owner table.boolean("isInstallMedium").notNullable(); // whether the image is just for installation (if not, it will be directly clonable) }), knex.schema.createTable("instances", (table) => { table.increments("id"); table.integer("userId").notNullable(); table.integer("imageId"); table.integer("lastInstallationMediaId"); table.text("comment"); table.text("customIdentifier"); table.enum("virtualizationType", ["kvm"]).notNullable(); table.integer("memory").notNullable(); // in MB table.integer("swap"); // in MB table.integer("diskSpace").notNullable(); // in MB table.integer("traffic"); // in MB table.boolean("suspended").notNullable(); table.text("suspensionReason"); table.boolean("terminated").notNullable(); table.text("terminationReason"); table.boolean("running"); }), knex.schema.createTable("users", (table) => { table.increments("id"); table.text("username").notNullable(); table.text("hash").notNullable(); table.text("emailAddress").notNullable(); table.boolean("active").notNullable(); }) ]); }; exports.down = function(knex, Promise) { return Promise.all([ knex.schema.dropTable("images"), knex.schema.dropTable("instances"), knex.schema.dropTable("users") ]); };