/* This file was generated by ODB, object-relational mapping (ORM)
 * compiler for C++.
 */

CREATE TABLE "build_auxiliary_machines" (
  "package_tenant" TEXT NOT NULL,
  "package_name" CITEXT NOT NULL,
  "package_version_epoch" INTEGER NOT NULL,
  "package_version_canonical_upstream" TEXT NOT NULL,
  "package_version_canonical_release" TEXT NOT NULL COLLATE "C",
  "package_version_revision" INTEGER NOT NULL,
  "target" TEXT NOT NULL,
  "target_config_name" TEXT NOT NULL,
  "package_config_name" TEXT NOT NULL,
  "toolchain_name" TEXT NOT NULL,
  "toolchain_version_epoch" INTEGER NOT NULL,
  "toolchain_version_canonical_upstream" TEXT NOT NULL,
  "toolchain_version_canonical_release" TEXT NOT NULL COLLATE "C",
  "toolchain_version_revision" INTEGER NOT NULL,
  "index" BIGINT NOT NULL,
  "name" TEXT NOT NULL,
  "summary" TEXT NOT NULL);

CREATE INDEX "build_auxiliary_machines_object_id_i"
  ON "build_auxiliary_machines" (
    "package_tenant",
    "package_name",
    "package_version_epoch",
    "package_version_canonical_upstream",
    "package_version_canonical_release",
    "package_version_revision",
    "target",
    "target_config_name",
    "package_config_name",
    "toolchain_name",
    "toolchain_version_epoch",
    "toolchain_version_canonical_upstream",
    "toolchain_version_canonical_release",
    "toolchain_version_revision");

CREATE INDEX "build_auxiliary_machines_index_i"
  ON "build_auxiliary_machines" ("index");

ALTER TABLE "build_auxiliary_machines"
  ADD CONSTRAINT "object_id_fk"
    FOREIGN KEY ("package_tenant",
                 "package_name",
                 "package_version_epoch",
                 "package_version_canonical_upstream",
                 "package_version_canonical_release",
                 "package_version_revision",
                 "target",
                 "target_config_name",
                 "package_config_name",
                 "toolchain_name",
                 "toolchain_version_epoch",
                 "toolchain_version_canonical_upstream",
                 "toolchain_version_canonical_release",
                 "toolchain_version_revision")
    REFERENCES "build" ("package_tenant",
                        "package_name",
                        "package_version_epoch",
                        "package_version_canonical_upstream",
                        "package_version_canonical_release",
                        "package_version_revision",
                        "target",
                        "target_config_name",
                        "package_config_name",
                        "toolchain_name",
                        "toolchain_version_epoch",
                        "toolchain_version_canonical_upstream",
                        "toolchain_version_canonical_release",
                        "toolchain_version_revision")
    ON DELETE CASCADE;

UPDATE "schema_version"
  SET "version" = 25, "migration" = TRUE
  WHERE "name" = 'build';

