20 lines
1.5 KiB
SQL
20 lines
1.5 KiB
SQL
-- +goose Up
|
|
-- create "document_blocks" table
|
|
CREATE TABLE "document_blocks" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, "content" character varying NOT NULL, "document_id" bigint NOT NULL, "user_id" character varying NOT NULL, "created_at" timestamptz NOT NULL, "updated_at" timestamptz NOT NULL, PRIMARY KEY ("id"));
|
|
-- create index "documentblock_name_user_id" to table: "document_blocks"
|
|
CREATE INDEX "documentblock_name_user_id" ON "document_blocks" ("name", "user_id");
|
|
-- create "documents" table
|
|
CREATE TABLE "documents" ("id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" character varying NOT NULL, "user_id" character varying NOT NULL, "created_at" timestamptz NOT NULL, "updated_at" timestamptz NOT NULL, "document_block_document" bigint NULL, PRIMARY KEY ("id"), CONSTRAINT "documents_document_blocks_document" FOREIGN KEY ("document_block_document") REFERENCES "document_blocks" ("id") ON DELETE SET NULL);
|
|
-- create index "document_name_user_id" to table: "documents"
|
|
CREATE INDEX "document_name_user_id" ON "documents" ("name", "user_id");
|
|
|
|
-- +goose Down
|
|
-- reverse: create index "document_name_user_id" to table: "documents"
|
|
DROP INDEX "document_name_user_id";
|
|
-- reverse: create "documents" table
|
|
DROP TABLE "documents";
|
|
-- reverse: create index "documentblock_name_user_id" to table: "document_blocks"
|
|
DROP INDEX "documentblock_name_user_id";
|
|
-- reverse: create "document_blocks" table
|
|
DROP TABLE "document_blocks";
|