greatape/components/model/repository/scripts/category_type.sql

41 wiersze
1.2 KiB
SQL

##########
CREATE TABLE "category_types_history"
(
"id" BIGSERIAL NOT NULL,
"action" VARCHAR(16) NOT NULL,
"original_id" BIGINT NOT NULL,
"description" VARCHAR(64) NOT NULL,
"editor" BIGINT NOT NULL,
"status" BIGINT NOT NULL,
"sort_order" REAL NOT NULL,
"queued_at" BIGINT NOT NULL,
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"triggered_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"changed_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"payload" JSONB NULL,
CONSTRAINT "pk_category_types_history" PRIMARY KEY ("id")
);
##########
CREATE TABLE "category_types"
(
"id" BIGINT NOT NULL,
"description" VARCHAR(64) NOT NULL,
"editor" BIGINT NOT NULL DEFAULT 0,
"status" BIGINT NOT NULL DEFAULT 0,
"sort_order" REAL NOT NULL DEFAULT 0,
"queued_at" BIGINT NOT NULL DEFAULT 0,
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
"payload" JSONB NULL,
CONSTRAINT "pk_category_types" PRIMARY KEY ("id")
);
##########
CREATE INDEX "idx_category_types_status" ON "category_types" ("status");