--
--


SET transaction_timeout = 0;



--
-- Name: archives; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.archives (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    code character varying,
    codeagency_code character varying,
    total_m_archives character varying,
    permanent_vv character varying(255),
    hs_cth character varying(255),
    hs_vv character varying(255),
    "desc" text,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    permanent_cth character varying,
    status character varying(10),
    slug character varying NOT NULL
);


ALTER TABLE public.archives OWNER TO thanh;

--
-- Name: archives_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.archives_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.archives_id_seq OWNER TO thanh;

--
-- Name: archives_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.archives_id_seq OWNED BY public.archives.id;


--
-- Name: failed_jobs; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.failed_jobs (
    id bigint NOT NULL,
    uuid character varying(255) NOT NULL,
    connection text NOT NULL,
    queue text NOT NULL,
    payload text NOT NULL,
    exception text NOT NULL,
    failed_at timestamp(0) without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);


ALTER TABLE public.failed_jobs OWNER TO thanh;

--
-- Name: failed_jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.failed_jobs_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.failed_jobs_id_seq OWNER TO thanh;

--
-- Name: failed_jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.failed_jobs_id_seq OWNED BY public.failed_jobs.id;


--
-- Name: migrations; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.migrations (
    id integer NOT NULL,
    migration character varying(255) NOT NULL,
    batch integer NOT NULL
);


ALTER TABLE public.migrations OWNER TO thanh;

--
-- Name: migrations_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.migrations_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.migrations_id_seq OWNER TO thanh;

--
-- Name: migrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.migrations_id_seq OWNED BY public.migrations.id;


--
-- Name: model_has_permissions; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.model_has_permissions (
    permission_id bigint NOT NULL,
    model_type character varying(255) NOT NULL,
    model_id bigint NOT NULL
);


ALTER TABLE public.model_has_permissions OWNER TO thanh;

--
-- Name: model_has_roles; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.model_has_roles (
    role_id bigint NOT NULL,
    model_type character varying(255) NOT NULL,
    model_id bigint NOT NULL
);


ALTER TABLE public.model_has_roles OWNER TO thanh;

--
-- Name: organizational; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.organizational (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    parent_id integer DEFAULT 0,
    code character varying(255),
    "desc" text,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


ALTER TABLE public.organizational OWNER TO thanh;

--
-- Name: organizational_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.organizational_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.organizational_id_seq OWNER TO thanh;

--
-- Name: organizational_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.organizational_id_seq OWNED BY public.organizational.id;

--
-- Name: permissions; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.permissions (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    guard_name character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    full_name character varying NOT NULL
);


ALTER TABLE public.permissions OWNER TO thanh;

--
-- Name: permissions_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.permissions_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.permissions_id_seq OWNER TO thanh;

--
-- Name: permissions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.permissions_id_seq OWNED BY public.permissions.id;

--
-- Name: personal_access_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.personal_access_tokens_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.personal_access_tokens_id_seq OWNER TO thanh;

--
-- Name: personal_access_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.personal_access_tokens_id_seq OWNED BY public.personal_access_tokens.id;


--
-- Name: postion; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.postion (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    parent_id integer NOT NULL,
    "desc" character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone
);


ALTER TABLE public.postion OWNER TO thanh;

--
-- Name: postion_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.postion_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.postion_id_seq OWNER TO thanh;

--
-- Name: postion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.postion_id_seq OWNED BY public.postion.id;


--
-- Name: role_has_permissions; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.role_has_permissions (
    permission_id bigint NOT NULL,
    role_id bigint NOT NULL
);


ALTER TABLE public.role_has_permissions OWNER TO thanh;

--
-- Name: roles; Type: TABLE; Schema: public; Owner: thanh
--

CREATE TABLE public.roles (
    id bigint NOT NULL,
    name character varying(255) NOT NULL,
    guard_name character varying(255) NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    "desc" character varying
);


ALTER TABLE public.roles OWNER TO thanh;

--
-- Name: roles_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.roles_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.roles_id_seq OWNER TO thanh;

--
-- Name: roles_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.roles_id_seq OWNED BY public.roles.id;

--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: thanh
--

CREATE SEQUENCE public.users_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.users_id_seq OWNER TO thanh;

--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: thanh
--

ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;


--
-- Name: archives id; Type: DEFAULT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.archives ALTER COLUMN id SET DEFAULT nextval('public.archives_id_seq'::regclass);


--
-- Name: failed_jobs id; Type: DEFAULT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.failed_jobs ALTER COLUMN id SET DEFAULT nextval('public.failed_jobs_id_seq'::regclass);


--
-- Name: migrations id; Type: DEFAULT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.migrations ALTER COLUMN id SET DEFAULT nextval('public.migrations_id_seq'::regclass);


--
-- Name: organizational id; Type: DEFAULT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.organizational ALTER COLUMN id SET DEFAULT nextval('public.organizational_id_seq'::regclass);


--
-- Name: permissions id; Type: DEFAULT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.permissions ALTER COLUMN id SET DEFAULT nextval('public.permissions_id_seq'::regclass);


--
-- Name: postion id; Type: DEFAULT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.postion ALTER COLUMN id SET DEFAULT nextval('public.postion_id_seq'::regclass);


--
-- Name: roles id; Type: DEFAULT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.roles ALTER COLUMN id SET DEFAULT nextval('public.roles_id_seq'::regclass);


--
-- Data for Name: archives; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.archives (id, name, code, codeagency_code, total_m_archives, permanent_vv, hs_cth, hs_vv, "desc", created_at, updated_at, permanent_cth, status, slug) FROM stdin;
3	Phòng Văn hoá	\N	\N	\N	\N	\N	\N	\N	2025-03-19 09:54:44	2025-03-19 09:54:44	\N	active	phong-van-hoa
6	Ủy ban nhân dân xã Thanh Thùy	\N	\N	\N	\N	\N	\N	\N	2025-03-20 08:29:57	2025-03-20 08:29:57	\N	active	uy-ban-nhan-dan-xa-thanh-thuy
4	Phòng Giáo dục và Đào tạo	\N	\N	\N	\N	\N	\N	\N	2025-03-19 09:54:55	2025-03-20 09:27:21	\N	inactive	phong-giao-duc-va-dao-tao
2	Phòng Lao động thương binh và Xã hội	\N	\N	\N	\N	\N	\N	\N	2025-03-19 09:53:01	2025-03-20 09:27:40	\N	inactive	phong-lao-dong-thuong-binh-va-xa-hoi
\.


--
-- Data for Name: failed_jobs; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.failed_jobs (id, uuid, connection, queue, payload, exception, failed_at) FROM stdin;
\.


--
-- Data for Name: migrations; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.migrations (id, migration, batch) FROM stdin;
1	2014_10_12_000000_create_users_table	1
2	2014_10_12_100000_create_password_reset_tokens_table	1
3	2019_08_19_000000_create_failed_jobs_table	1
4	2019_12_14_000001_create_personal_access_tokens_table	1
5	2025_03_11_082000_create_permission_tables	1
6	2025_03_16_151738_create_postion_table	2
7	2025_03_16_152809_create_organizational_table	3
8	2025_03_16_172500_update_users_table	4
9	2025_03_19_020402_create_warehouses_table	5
10	2025_03_19_025530_create_archives_table	5
11	2025_03_20_040531_create_records_table	6
\.


--
-- Data for Name: model_has_permissions; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.model_has_permissions (permission_id, model_type, model_id) FROM stdin;
\.


--
-- Data for Name: model_has_roles; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.model_has_roles (role_id, model_type, model_id) FROM stdin;
1	App\\Models\\User	1
4	App\\Models\\User	17
\.


--
-- Data for Name: organizational; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.organizational (id, name, parent_id, code, "desc", created_at, updated_at) FROM stdin;
1	Phòng quản lý đô thị	0	\N	Phụ trách phòng quản lý đô thị	\N	\N
2	Phòng tài chính	1	\N	Phụ trách phòng tài chính	\N	2025-03-19 03:59:12
\.


--
-- Data for Name: permissions; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.permissions (id, name, guard_name, created_at, updated_at, full_name) FROM stdin;
49	organizational.list	web	2025-03-18 08:26:26	2025-03-18 08:26:26	Xem danh sách phòng ban
50	organizational.create	web	2025-03-18 08:27:00	2025-03-18 08:27:00	Thêm mới phòng ban
51	organizational.edit	web	2025-03-18 08:27:14	2025-03-18 08:27:14	Sửa phòng ban
52	organizational.delete	web	2025-03-18 08:27:52	2025-03-18 08:27:52	Xóa phòng ban
53	role.edit	web	2025-03-20 11:00:30	2025-03-20 11:00:30	Sửa vai trò
54	role.delete	web	2025-03-20 11:00:46	2025-03-20 11:00:46	Xóa vai trò
2	permission.create	web	2025-03-13 14:50:22	2025-03-13 14:50:22	Thêm mới quyền
3	permission.edit	web	2025-03-13 14:55:14	2025-03-13 14:55:14	Sửa quyền
4	permission.delete	web	2025-03-13 14:59:16	2025-03-13 14:59:16	Xóa quyền
42	permission.list	web	2025-03-15 15:35:57	2025-03-15 15:35:57	Xem danh sách quyền
43	user.list	web	2025-03-17 05:39:52	2025-03-17 05:39:52	Xem danh sách tài khoản
44	user.create	web	2025-03-17 05:40:19	2025-03-17 05:40:19	Thêm mới tài khoản
45	user.edit	web	2025-03-17 05:40:33	2025-03-17 05:40:33	Sửa tài khoản
46	user.delete	web	2025-03-17 05:40:47	2025-03-17 05:40:47	Xóa tài khoản
47	role.list	web	2025-03-18 03:26:41	2025-03-18 03:26:41	Xem danh sách vai trò
\.


--
-- Data for Name: postion; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.postion (id, name, parent_id, "desc", created_at, updated_at) FROM stdin;
1	Giám đốc	0	Giám đốc	\N	\N
2	Trưởng Phòng	1	Trưởng phòng	\N	\N
\.


--
-- Data for Name: role_has_permissions; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.role_has_permissions (permission_id, role_id) FROM stdin;
2	4
3	4
4	4
43	4
44	4
45	4
47	4
49	4
50	4
51	4
52	4
53	4
54	4
42	4
\.


--
-- Data for Name: roles; Type: TABLE DATA; Schema: public; Owner: thanh
--

COPY public.roles (id, name, guard_name, created_at, updated_at, "desc") FROM stdin;
4	Quản trị viên	web	2025-03-16 12:41:23	2025-03-16 12:41:23	Có đầy đủ các quyền trong hệ thống
1	super-admin	web	2025-03-13 08:37:06	2025-03-13 08:37:06	\N
\.



--
-- Name: archives archives_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.archives
    ADD CONSTRAINT archives_pkey PRIMARY KEY (id);


--
-- Name: failed_jobs failed_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.failed_jobs
    ADD CONSTRAINT failed_jobs_pkey PRIMARY KEY (id);


--
-- Name: failed_jobs failed_jobs_uuid_unique; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.failed_jobs
    ADD CONSTRAINT failed_jobs_uuid_unique UNIQUE (uuid);


--
-- Name: migrations migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.migrations
    ADD CONSTRAINT migrations_pkey PRIMARY KEY (id);


--
-- Name: model_has_permissions model_has_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.model_has_permissions
    ADD CONSTRAINT model_has_permissions_pkey PRIMARY KEY (permission_id, model_id, model_type);


--
-- Name: model_has_roles model_has_roles_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.model_has_roles
    ADD CONSTRAINT model_has_roles_pkey PRIMARY KEY (role_id, model_id, model_type);


--
-- Name: organizational organizational_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.organizational
    ADD CONSTRAINT organizational_pkey PRIMARY KEY (id);


--
-- Name: permissions permissions_name_guard_name_unique; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.permissions
    ADD CONSTRAINT permissions_name_guard_name_unique UNIQUE (name, guard_name);


--
-- Name: permissions permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.permissions
    ADD CONSTRAINT permissions_pkey PRIMARY KEY (id);


--
-- Name: postion postion_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.postion
    ADD CONSTRAINT postion_pkey PRIMARY KEY (id);


--
-- Name: role_has_permissions role_has_permissions_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.role_has_permissions
    ADD CONSTRAINT role_has_permissions_pkey PRIMARY KEY (permission_id, role_id);


--
-- Name: roles roles_name_guard_name_unique; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_name_guard_name_unique UNIQUE (name, guard_name);


--
-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.roles
    ADD CONSTRAINT roles_pkey PRIMARY KEY (id);


--
-- Name: model_has_permissions_model_id_model_type_index; Type: INDEX; Schema: public; Owner: thanh
--

CREATE INDEX model_has_permissions_model_id_model_type_index ON public.model_has_permissions USING btree (model_id, model_type);


--
-- Name: model_has_roles_model_id_model_type_index; Type: INDEX; Schema: public; Owner: thanh
--

CREATE INDEX model_has_roles_model_id_model_type_index ON public.model_has_roles USING btree (model_id, model_type);


--
-- Name: model_has_permissions model_has_permissions_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.model_has_permissions
    ADD CONSTRAINT model_has_permissions_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON DELETE CASCADE;


--
-- Name: model_has_roles model_has_roles_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.model_has_roles
    ADD CONSTRAINT model_has_roles_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE;


--
-- Name: role_has_permissions role_has_permissions_permission_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.role_has_permissions
    ADD CONSTRAINT role_has_permissions_permission_id_foreign FOREIGN KEY (permission_id) REFERENCES public.permissions(id) ON DELETE CASCADE;


--
-- Name: role_has_permissions role_has_permissions_role_id_foreign; Type: FK CONSTRAINT; Schema: public; Owner: thanh
--

ALTER TABLE ONLY public.role_has_permissions
    ADD CONSTRAINT role_has_permissions_role_id_foreign FOREIGN KEY (role_id) REFERENCES public.roles(id) ON DELETE CASCADE;


--
--

