308 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			SQL
		
	
	
	
	
	
			
		
		
	
	
			308 lines
		
	
	
		
			7.9 KiB
		
	
	
	
		
			SQL
		
	
	
	
	
	
--
 | 
						|
-- PostgreSQL database dump
 | 
						|
--
 | 
						|
 | 
						|
-- Dumped from database version 15.3
 | 
						|
-- Dumped by pg_dump version 15.3
 | 
						|
 | 
						|
SET statement_timeout = 0;
 | 
						|
SET lock_timeout = 0;
 | 
						|
SET idle_in_transaction_session_timeout = 0;
 | 
						|
SET client_encoding = 'UTF8';
 | 
						|
SET standard_conforming_strings = on;
 | 
						|
SELECT pg_catalog.set_config('search_path', '', false);
 | 
						|
SET check_function_bodies = false;
 | 
						|
SET xmloption = content;
 | 
						|
SET client_min_messages = warning;
 | 
						|
SET row_security = off;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: myapp_development; Type: DATABASE; Schema: -; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE DATABASE myapp_development WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE = 'en_US.UTF-8';
 | 
						|
 | 
						|
ALTER DATABASE myapp_development OWNER TO postgres;
 | 
						|
 | 
						|
\connect myapp_development
 | 
						|
 | 
						|
SET statement_timeout = 0;
 | 
						|
SET lock_timeout = 0;
 | 
						|
SET idle_in_transaction_session_timeout = 0;
 | 
						|
SET client_encoding = 'UTF8';
 | 
						|
SET standard_conforming_strings = on;
 | 
						|
SELECT pg_catalog.set_config('search_path', '', false);
 | 
						|
SET check_function_bodies = false;
 | 
						|
SET xmloption = content;
 | 
						|
SET client_min_messages = warning;
 | 
						|
SET row_security = off;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE TABLE public.schema_migrations (
 | 
						|
    version character varying(255) NOT NULL
 | 
						|
);
 | 
						|
 | 
						|
ALTER TABLE public.schema_migrations OWNER TO postgres;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE TABLE public.users (
 | 
						|
    id integer NOT NULL,
 | 
						|
    name character varying(255) NOT NULL,
 | 
						|
    email character varying(255) NOT NULL,
 | 
						|
    phone character varying(20),
 | 
						|
    first_name character varying(50) NOT NULL,
 | 
						|
    middle_name character varying(50),
 | 
						|
    last_name character varying(50) NOT NULL,
 | 
						|
    status_id smallint,
 | 
						|
    mfa_kind character varying(50) DEFAULT 'None'::character varying,
 | 
						|
    search_vector tsvector,
 | 
						|
    created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP,
 | 
						|
    updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
 | 
						|
);
 | 
						|
 | 
						|
ALTER TABLE public.users OWNER TO postgres;
 | 
						|
 | 
						|
 | 
						|
CREATE TABLE public.user_sessions (
 | 
						|
    id character varying NOT NULL,
 | 
						|
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
 | 
						|
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
 | 
						|
    expires_at timestamp with time zone NOT NULL,
 | 
						|
    branch_id bigint,
 | 
						|
    user_id bigint NOT NULL,
 | 
						|
    role_id smallint,
 | 
						|
    login_ip character varying NOT NULL,
 | 
						|
);
 | 
						|
 | 
						|
CREATE TABLE public.branch_users (
 | 
						|
    branch_id bigint NOT NULL,
 | 
						|
    user_id bigint NOT NULL,
 | 
						|
    role_id smallint NOT NULL,
 | 
						|
    created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
 | 
						|
    updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
 | 
						|
);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE SEQUENCE public.users_id_seq
 | 
						|
    AS integer
 | 
						|
    START WITH 1
 | 
						|
    INCREMENT BY 1
 | 
						|
    NO MINVALUE
 | 
						|
    NO MAXVALUE
 | 
						|
    CACHE 1;
 | 
						|
 | 
						|
ALTER TABLE public.users_id_seq OWNER TO postgres;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: posts; Type: TABLE; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE TABLE public.posts (
 | 
						|
    id integer NOT NULL,
 | 
						|
    user_id integer NOT NULL,
 | 
						|
    title character varying(255) NOT NULL,
 | 
						|
    content text,
 | 
						|
    created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
 | 
						|
);
 | 
						|
 | 
						|
ALTER TABLE public.posts OWNER TO postgres;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: posts_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE SEQUENCE public.posts_id_seq
 | 
						|
    AS integer
 | 
						|
    START WITH 1
 | 
						|
    INCREMENT BY 1
 | 
						|
    NO MINVALUE
 | 
						|
    NO MAXVALUE
 | 
						|
    CACHE 1;
 | 
						|
 | 
						|
ALTER TABLE public.posts_id_seq OWNER TO postgres;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: posts_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER SEQUENCE public.posts_id_seq OWNED BY public.posts.id;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: comments; Type: TABLE; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE TABLE public.comments (
 | 
						|
    id integer NOT NULL,
 | 
						|
    post_id integer NOT NULL,
 | 
						|
    user_id integer NOT NULL,
 | 
						|
    content text NOT NULL,
 | 
						|
    created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
 | 
						|
);
 | 
						|
 | 
						|
ALTER TABLE public.comments OWNER TO postgres;
 | 
						|
 | 
						|
CREATE TABLE public.employees (
 | 
						|
    id integer NOT NULL,
 | 
						|
    name var NOT NULL,
 | 
						|
    department var NOT NULL,
 | 
						|
    salary decimal(10,2) ,
 | 
						|
    created_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
 | 
						|
    updated_at timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
 | 
						|
);
 | 
						|
--
 | 
						|
-- Name: comments_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE SEQUENCE public.comments_id_seq
 | 
						|
    AS integer
 | 
						|
    START WITH 1
 | 
						|
    INCREMENT BY 1
 | 
						|
    NO MINVALUE
 | 
						|
    NO MAXVALUE
 | 
						|
    CACHE 1;
 | 
						|
 | 
						|
ALTER TABLE public.comments_id_seq OWNER TO postgres;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: comments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER SEQUENCE public.comments_id_seq OWNED BY public.comments.id;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: posts id; Type: DEFAULT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.posts ALTER COLUMN id SET DEFAULT nextval('public.posts_id_seq'::regclass);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: comments id; Type: DEFAULT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.comments ALTER COLUMN id SET DEFAULT nextval('public.comments_id_seq'::regclass);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.schema_migrations
 | 
						|
    ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.users
 | 
						|
    ADD CONSTRAINT users_email_key UNIQUE (email);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.users
 | 
						|
    ADD CONSTRAINT users_pkey PRIMARY KEY (id);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: posts posts_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.posts
 | 
						|
    ADD CONSTRAINT posts_pkey PRIMARY KEY (id);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: comments comments_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.comments
 | 
						|
    ADD CONSTRAINT comments_pkey PRIMARY KEY (id);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: idx_comments_post_id; Type: INDEX; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE INDEX idx_comments_post_id ON public.comments USING btree (post_id);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: idx_comments_user_id; Type: INDEX; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE INDEX idx_comments_user_id ON public.comments USING btree (user_id);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: idx_posts_user_id; Type: INDEX; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
CREATE INDEX idx_posts_user_id ON public.posts USING btree (user_id);
 | 
						|
 | 
						|
--
 | 
						|
-- Name: posts posts_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.posts
 | 
						|
    ADD CONSTRAINT posts_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: comments comments_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.comments
 | 
						|
    ADD CONSTRAINT comments_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.posts(id) ON DELETE CASCADE;
 | 
						|
 | 
						|
--
 | 
						|
-- Name: comments comments_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
ALTER TABLE ONLY public.comments
 | 
						|
    ADD CONSTRAINT comments_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE;
 | 
						|
 | 
						|
--
 | 
						|
-- Data for Name: schema_migrations; Type: TABLE DATA; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
COPY public.schema_migrations (version) FROM stdin;
 | 
						|
20200227231541
 | 
						|
20200227231542
 | 
						|
20200227231543
 | 
						|
\.
 | 
						|
 | 
						|
--
 | 
						|
-- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
COPY public.users (id, name, email, created_at) FROM stdin;
 | 
						|
\.
 | 
						|
 | 
						|
--
 | 
						|
-- Data for Name: posts; Type: TABLE DATA; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
COPY public.posts (id, user_id, title, content, created_at) FROM stdin;
 | 
						|
\.
 | 
						|
 | 
						|
--
 | 
						|
-- Data for Name: comments; Type: TABLE DATA; Schema: public; Owner: postgres
 | 
						|
--
 | 
						|
 | 
						|
COPY public.comments (id, post_id, user_id, content, created_at)
 |