· 6 years ago · Jun 26, 2019, 10:58 PM
1GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO postgres;
2GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO postgres;
3GRANT USAGE, SELECT ON SEQUENCE users_id_seq TO postgres;
4
5DROP TABLE IF EXISTS public.user_role;
6CREATE TYPE public.user_role AS ENUM (
7 'admin',
8 'user'
9 );
10
11DROP SEQUENCE IF EXISTS public.users_id_seq;
12
13CREATE SEQUENCE public.users_id_seq
14 START WITH 1000
15 INCREMENT BY 1
16 NO MINVALUE
17 NO MAXVALUE
18 CACHE 1;
19
20DROP TABLE IF EXISTS public.users;
21
22CREATE TABLE public.users
23(
24 id integer NOT NULL DEFAULT nextval('users_id_seq'::regclass),
25 email character varying NOT NULL DEFAULT ''::character varying,
26 encrypted_password character varying DEFAULT ''::character varying,
27 reset_password_token character varying,
28 reset_password_sent_at timestamp without time zone,
29 remember_created_at timestamp without time zone,
30 sign_in_count integer NOT NULL DEFAULT 0,
31 current_sign_in_at timestamp without time zone,
32 last_sign_in_at timestamp without time zone,
33 current_sign_in_ip inet,
34 last_sign_in_ip inet,
35 created_at timestamp without time zone NOT NULL,
36 updated_at timestamp without time zone NOT NULL,
37 authentication_token character varying(30),
38 first_name character varying,
39 last_name character varying,
40 nickname character varying,
41 avatar character varying,
42 role user_role,
43 uuid character varying,
44 cmt_authentication_token character varying,
45 slug character varying,
46 discarded_at timestamp without time zone,
47 member_id character varying,
48 phone_number character varying,
49 address character varying,
50 age character varying,
51 gender character varying,
52 marketing_preferences json DEFAULT '{}'::json,
53 dob character varying,
54 flipper_id integer,
55 rego_number character varying,
56 invitation_token character varying,
57 invitation_created_at timestamp without time zone,
58 invitation_sent_at timestamp without time zone,
59 invitation_accepted_at timestamp without time zone,
60 invitation_limit integer,
61 invited_by_id integer,
62 invited_by_type character varying,
63 raxel_uid character varying,
64 password_changed timestamp without time zone,
65 CONSTRAINT users_pkey PRIMARY KEY (id)
66)
67 WITH (
68 OIDS=FALSE
69 );
70ALTER TABLE public.users OWNER TO ubicar_staging;
71
72-- Index: public.index_users_on_authentication_token
73
74-- DROP INDEX public.index_users_on_authentication_token;
75
76CREATE UNIQUE INDEX index_users_on_authentication_token
77 ON public.users
78 USING btree
79 (authentication_token COLLATE pg_catalog."default");
80
81-- Index: public.index_users_on_discarded_at
82
83-- DROP INDEX public.index_users_on_discarded_at;
84
85CREATE INDEX index_users_on_discarded_at
86 ON public.users
87 USING btree
88 (discarded_at);
89
90-- Index: public.index_users_on_email
91
92-- DROP INDEX public.index_users_on_email;
93
94CREATE UNIQUE INDEX index_users_on_email
95 ON public.users
96 USING btree
97 (email COLLATE pg_catalog."default");
98
99-- Index: public.index_users_on_invitation_token
100
101-- DROP INDEX public.index_users_on_invitation_token;
102
103CREATE UNIQUE INDEX index_users_on_invitation_token
104 ON public.users
105 USING btree
106 (invitation_token COLLATE pg_catalog."default");
107
108-- Index: public.index_users_on_nickname
109
110-- DROP INDEX public.index_users_on_nickname;
111
112CREATE UNIQUE INDEX index_users_on_nickname
113 ON public.users
114 USING btree
115 (nickname COLLATE pg_catalog."default");
116
117-- Index: public.index_users_on_reset_password_token
118
119-- DROP INDEX public.index_users_on_reset_password_token;
120
121CREATE UNIQUE INDEX index_users_on_reset_password_token
122 ON public.users
123 USING btree
124 (reset_password_token COLLATE pg_catalog."default");
125
126-- Index: public.index_users_on_slug
127
128-- DROP INDEX public.index_users_on_slug;
129
130CREATE INDEX index_users_on_slug
131 ON public.users
132 USING btree
133 (slug COLLATE pg_catalog."default");
134
135-- Index: public.index_users_on_uuid
136
137-- DROP INDEX public.index_users_on_uuid;
138
139CREATE UNIQUE INDEX index_users_on_uuid
140 ON public.users
141 USING btree
142 (uuid COLLATE pg_catalog."default");