
/* SuratF(iles) untuk upload surat+lampiran */
/* struktur copas dari attachments */

CREATE SEQUENCE IF NOT EXISTS suratf_pk_ai; COMMIT;

CREATE TABLE IF NOT EXISTS suratf (
	pk INTEGER NOT NULL DEFAULT nextval('suratf_pk_ai'),
	pk_surat INTEGER NOT NULL,
	"name" VARCHAR(256) DEFAULT NULL,
	"path" VARCHAR(512) DEFAULT NULL,
	"type" VARCHAR(128) DEFAULT NULL,
	"size" INTEGER DEFAULT 0,
	created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
	updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
	CONSTRAINT suratf_pk PRIMARY KEY (pk),
	CONSTRAINT suratf_surat_fk FOREIGN KEY (pk_surat) REFERENCES surat (pk) ON DELETE CASCADE ON UPDATE CASCADE
);
COMMIT;

ALTER SEQUENCE suratf_pk_ai OWNED BY suratf.pk; COMMIT;
