-- DDL Statements generated by YAML Shredder
-- Dialect: SNOWFLAKE
-- Tables: 3

-- Table: deployments
CREATE TABLE "deployments" (
    "id" NUMBER NOT NULL,
    "deployment_code" VARCHAR(9) NOT NULL,
    "name" VARCHAR(30) NOT NULL,
    "active" BOOLEAN NOT NULL
,
    PRIMARY KEY ("id")
);

-- Table: communities
CREATE TABLE "communities" (
    "id" NUMBER NOT NULL,
    "parent_id" NUMBER NOT NULL,
    "name" VARCHAR(16) NOT NULL,
    "population" NUMBER NOT NULL
,
    PRIMARY KEY ("id")
);
ALTER TABLE "communities" ADD CONSTRAINT "FK_communities_deployments_id" FOREIGN KEY ("parent_id") REFERENCES "deployments"("id");

-- Table: sensor_actions
CREATE TABLE "sensor_actions" (
    "id" NUMBER NOT NULL,
    "parent_id" NUMBER NOT NULL,
    "sensor_type" VARCHAR(16) NOT NULL,
    "threshold" FLOAT NULL,
    "enabled" BOOLEAN NOT NULL
,
    PRIMARY KEY ("id")
);
ALTER TABLE "sensor_actions" ADD CONSTRAINT "FK_sensor_actions_deployments_id" FOREIGN KEY ("parent_id") REFERENCES "deployments"("id");

