sipd-transaksi-master/migrations/000005_create_mst_prioritas_kab_kota_table.up.sql
2025-09-16 08:42:27 +07:00

36 lines
2.8 KiB
SQL

CREATE TABLE IF NOT EXISTS public.mst_prioritas_kab_kota (
id_unik_prioritas_kab_kota uuid DEFAULT public.uuid_generate_v7() NOT NULL,
id_label_kokab_lama integer DEFAULT 0 NOT NULL,
tahun integer DEFAULT 0 NOT NULL,
id_daerah integer DEFAULT 0 NOT NULL,
locked boolean DEFAULT false NOT NULL,
nama_prioritas text DEFAULT ''::text NOT NULL,
created_at timestamp(6) without time zone DEFAULT now() NOT NULL,
created_by integer DEFAULT 0 NOT NULL,
updated_at timestamp(6) without time zone DEFAULT '0001-01-01 00:00:00'::timestamp without time zone NOT NULL,
updated_by integer DEFAULT 0 NOT NULL,
deleted_at timestamp(6) without time zone DEFAULT '0001-01-01 00:00:00'::timestamp without time zone NOT NULL,
deleted_by integer DEFAULT 0 NOT NULL
);
ALTER TABLE public.mst_prioritas_kab_kota ADD CONSTRAINT mst_prioritas_kab_kota_pkey PRIMARY KEY (id_unik_prioritas_kab_kota, tahun, id_daerah);
ALTER TABLE public.mst_prioritas_kab_kota ADD CONSTRAINT mst_prioritas_kab_kota_unique_key UNIQUE (tahun, id_daerah, nama_prioritas);
COMMENT ON TABLE public.mst_prioritas_kab_kota IS 'Tabel berisi label atau tagging prioritas pembangunan pemerintah daerah kab/kota.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.id_unik_prioritas_kab_kota IS 'ID unik UUID sebagai ID primary key.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.id_label_kokab_lama IS 'Primary key tabel lama.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.tahun IS 'Tahun prioritas kab/kota.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.locked IS 'Status prioritas dapat dipilih atau tidak (true/false).';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.id_daerah IS 'ID daerah kab/kota.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.nama_prioritas IS 'Nama prioritas pembangunan tingkat kab/kota.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.created_at IS 'Tanggal dan waktu data dibuat.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.created_by IS 'ID pengguna yang membuat data.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.updated_at IS 'Tanggal dan waktu terakhir data diperbarui.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.updated_by IS 'ID pengguna yang memperbarui data.';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.deleted_at IS 'Tanggal dan waktu data dihapus (soft delete).';
COMMENT ON COLUMN public.mst_prioritas_kab_kota.deleted_by IS 'ID pengguna yang menghapus data.';
CREATE INDEX mst_prioritas_kab_kota_id_unik_prioritas_kab_kota_idx ON public.mst_prioritas_kab_kota USING btree (id_unik_prioritas_kab_kota);
CREATE INDEX mst_prioritas_kab_kota_tahun_idx ON public.mst_prioritas_kab_kota USING btree (tahun);
CREATE INDEX mst_prioritas_kab_kota_id_daerah_idx ON public.mst_prioritas_kab_kota USING btree (id_daerah);
CREATE INDEX mst_prioritas_kab_kota_nama_prioritas_idx ON public.mst_prioritas_kab_kota USING btree (nama_prioritas);