
-----------------------------------------------------------------------------
-- article
-----------------------------------------------------------------------------

DROP TABLE "article" CASCADE;


CREATE TABLE "article"
(
	"id" serial  NOT NULL,
	PRIMARY KEY ("id")
);

COMMENT ON TABLE "article" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- article_i18n
-----------------------------------------------------------------------------

DROP TABLE "article_i18n" CASCADE;


CREATE TABLE "article_i18n"
(
	"title" VARCHAR(256),
	"text" VARCHAR(16384),
	"id" INTEGER  NOT NULL,
	"culture" VARCHAR(7)  NOT NULL,
	PRIMARY KEY ("id","culture")
);

COMMENT ON TABLE "article_i18n" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- photo
-----------------------------------------------------------------------------

DROP TABLE "photo" CASCADE;


CREATE TABLE "photo"
(
	"id" serial  NOT NULL,
	"name" VARCHAR(64)  NOT NULL,
	"gallery_id" INTEGER,
	"created_at" TIMESTAMP,
	PRIMARY KEY ("id")
);

COMMENT ON TABLE "photo" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- photo_i18n
-----------------------------------------------------------------------------

DROP TABLE "photo_i18n" CASCADE;


CREATE TABLE "photo_i18n"
(
	"title" VARCHAR(256),
	"id" INTEGER  NOT NULL,
	"culture" VARCHAR(7)  NOT NULL,
	PRIMARY KEY ("id","culture")
);

COMMENT ON TABLE "photo_i18n" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- gallery
-----------------------------------------------------------------------------

DROP TABLE "gallery" CASCADE;


CREATE TABLE "gallery"
(
	"id" serial  NOT NULL,
	"created_at" TIMESTAMP,
	PRIMARY KEY ("id")
);

COMMENT ON TABLE "gallery" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- gallery_i18n
-----------------------------------------------------------------------------

DROP TABLE "gallery_i18n" CASCADE;


CREATE TABLE "gallery_i18n"
(
	"title" VARCHAR(256),
	"id" INTEGER  NOT NULL,
	"culture" VARCHAR(7)  NOT NULL,
	PRIMARY KEY ("id","culture")
);

COMMENT ON TABLE "gallery_i18n" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- link
-----------------------------------------------------------------------------

DROP TABLE "link" CASCADE;


CREATE TABLE "link"
(
	"id" serial  NOT NULL,
	"href" VARCHAR(128),
	"links_set_id" INTEGER,
	PRIMARY KEY ("id")
);

COMMENT ON TABLE "link" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- link_i18n
-----------------------------------------------------------------------------

DROP TABLE "link_i18n" CASCADE;


CREATE TABLE "link_i18n"
(
	"text" VARCHAR(64),
	"id" INTEGER  NOT NULL,
	"culture" VARCHAR(7)  NOT NULL,
	PRIMARY KEY ("id","culture")
);

COMMENT ON TABLE "link_i18n" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- links_set
-----------------------------------------------------------------------------

DROP TABLE "links_set" CASCADE;


CREATE TABLE "links_set"
(
	"id" serial  NOT NULL,
	"name" VARCHAR(64),
	PRIMARY KEY ("id")
);

COMMENT ON TABLE "links_set" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- bio_part
-----------------------------------------------------------------------------

DROP TABLE "bio_part" CASCADE;


CREATE TABLE "bio_part"
(
	"id" serial  NOT NULL,
	"ypos" INTEGER  NOT NULL,
	PRIMARY KEY ("id")
);

COMMENT ON TABLE "bio_part" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- bio_part_i18n
-----------------------------------------------------------------------------

DROP TABLE "bio_part_i18n" CASCADE;


CREATE TABLE "bio_part_i18n"
(
	"paragraph" VARCHAR(64),
	"title" VARCHAR(128),
	"text" VARCHAR(2048)  NOT NULL,
	"id" INTEGER  NOT NULL,
	"culture" VARCHAR(7)  NOT NULL,
	PRIMARY KEY ("id","culture")
);

COMMENT ON TABLE "bio_part_i18n" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- file
-----------------------------------------------------------------------------

DROP TABLE "file" CASCADE;


CREATE TABLE "file"
(
	"id" serial  NOT NULL,
	"name" VARCHAR(64),
	"ext" VARCHAR(8),
	"size" INTEGER,
	"files_set_id" INTEGER,
	PRIMARY KEY ("id")
);

COMMENT ON TABLE "file" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- file_i18n
-----------------------------------------------------------------------------

DROP TABLE "file_i18n" CASCADE;


CREATE TABLE "file_i18n"
(
	"text" VARCHAR(32),
	"id" INTEGER  NOT NULL,
	"culture" VARCHAR(7)  NOT NULL,
	PRIMARY KEY ("id","culture")
);

COMMENT ON TABLE "file_i18n" IS '';


SET search_path TO public;
-----------------------------------------------------------------------------
-- files_set
-----------------------------------------------------------------------------

DROP TABLE "files_set" CASCADE;


CREATE TABLE "files_set"
(
	"id" serial  NOT NULL,
	"name" VARCHAR(64),
	PRIMARY KEY ("id")
);

COMMENT ON TABLE "files_set" IS '';


SET search_path TO public;
ALTER TABLE "article_i18n" ADD CONSTRAINT "article_i18n_FK_1" FOREIGN KEY ("id") REFERENCES "article" ("id") ON DELETE CASCADE;

ALTER TABLE "photo" ADD CONSTRAINT "photo_FK_1" FOREIGN KEY ("gallery_id") REFERENCES "gallery" ("id") ON DELETE CASCADE;

ALTER TABLE "photo_i18n" ADD CONSTRAINT "photo_i18n_FK_1" FOREIGN KEY ("id") REFERENCES "photo" ("id") ON DELETE CASCADE;

ALTER TABLE "gallery_i18n" ADD CONSTRAINT "gallery_i18n_FK_1" FOREIGN KEY ("id") REFERENCES "gallery" ("id") ON DELETE CASCADE;

ALTER TABLE "link" ADD CONSTRAINT "link_FK_1" FOREIGN KEY ("links_set_id") REFERENCES "links_set" ("id") ON DELETE CASCADE;

ALTER TABLE "link_i18n" ADD CONSTRAINT "link_i18n_FK_1" FOREIGN KEY ("id") REFERENCES "link" ("id") ON DELETE CASCADE;

ALTER TABLE "bio_part_i18n" ADD CONSTRAINT "bio_part_i18n_FK_1" FOREIGN KEY ("id") REFERENCES "bio_part" ("id") ON DELETE CASCADE;

ALTER TABLE "file" ADD CONSTRAINT "file_FK_1" FOREIGN KEY ("files_set_id") REFERENCES "files_set" ("id") ON DELETE CASCADE;

ALTER TABLE "file_i18n" ADD CONSTRAINT "file_i18n_FK_1" FOREIGN KEY ("id") REFERENCES "file" ("id") ON DELETE CASCADE;
