forked from Act-Voyager/Act
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pg2dbic.sql
107 lines (58 loc) · 3.01 KB
/
pg2dbic.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
-- Convert schema 'pg.dump' to 'pg_dbic.dump':;
BEGIN;
DROP INDEX bios_idx;
ALTER TABLE bios ADD CONSTRAINT bios_idx UNIQUE (user_id, lang);
DROP INDEX events_idx;
ALTER TABLE invoices DROP CONSTRAINT invoices_order_id_fkey;
DROP INDEX invoices_idx;
CREATE INDEX invoices_idx_order_id on invoices (order_id);
ALTER TABLE invoices ADD CONSTRAINT invoices_idx UNIQUE (order_id);
ALTER TABLE invoices ADD CONSTRAINT invoices_fk_order_id FOREIGN KEY (order_id)
REFERENCES orders (order_id) DEFERRABLE;
ALTER TABLE news_items DROP CONSTRAINT news_items_news_id_fkey;
CREATE INDEX news_items_idx_news_id on news_items (news_id);
ALTER TABLE news_items ADD CONSTRAINT news_items_fk_news_id FOREIGN KEY (news_id)
REFERENCES news (news_id) DEFERRABLE;
ALTER TABLE order_items DROP CONSTRAINT order_items_order_id_fkey;
CREATE INDEX order_items_idx_order_id on order_items (order_id);
ALTER TABLE order_items ADD CONSTRAINT order_items_fk_order_id FOREIGN KEY (order_id)
REFERENCES orders (order_id) DEFERRABLE;
ALTER TABLE orders DROP CONSTRAINT orders_user_id_fkey;
CREATE INDEX orders_idx_user_id on orders (user_id);
ALTER TABLE orders ADD CONSTRAINT orders_fk_user_id FOREIGN KEY (user_id)
REFERENCES users (user_id) DEFERRABLE;
ALTER TABLE participations DROP CONSTRAINT participations_user_id_fkey;
DROP INDEX participations_idx;
CREATE INDEX participations_idx_user_id on participations (user_id);
ALTER TABLE participations ADD CONSTRAINT participations_fk_user_id FOREIGN KEY (user_id)
REFERENCES users (user_id) DEFERRABLE;
DROP INDEX pm_groups_idx;
ALTER TABLE rights DROP CONSTRAINT rights_user_id_fkey;
DROP INDEX rights_idx;
CREATE INDEX rights_idx_user_id on rights (user_id);
ALTER TABLE rights ADD CONSTRAINT rights_fk_user_id FOREIGN KEY (user_id)
REFERENCES users (user_id) DEFERRABLE;
ALTER TABLE talks DROP CONSTRAINT talks_track_id_fkey;
ALTER TABLE talks DROP CONSTRAINT talks_user_id_fkey;
DROP INDEX talks_idx;
CREATE INDEX talks_idx_track_id on talks (track_id);
CREATE INDEX talks_idx_user_id on talks (user_id);
ALTER TABLE talks ADD CONSTRAINT talks_fk_track_id FOREIGN KEY (track_id)
REFERENCES tracks (track_id) ON DELETE set null DEFERRABLE;
ALTER TABLE talks ADD CONSTRAINT talks_fk_user_id FOREIGN KEY (user_id)
REFERENCES users (user_id) DEFERRABLE;
DROP INDEX tracks_idx;
ALTER TABLE user_talks DROP CONSTRAINT user_talks_talk_id_fkey;
ALTER TABLE user_talks DROP CONSTRAINT user_talks_user_id_fkey;
DROP INDEX user_talks_idx;
CREATE INDEX user_talks_idx_talk_id on user_talks (talk_id);
CREATE INDEX user_talks_idx_user_id on user_talks (user_id);
ALTER TABLE user_talks ADD CONSTRAINT user_talks_fk_talk_id FOREIGN KEY (talk_id)
REFERENCES talks (talk_id) DEFERRABLE;
ALTER TABLE user_talks ADD CONSTRAINT user_talks_fk_user_id FOREIGN KEY (user_id)
REFERENCES users (user_id) DEFERRABLE;
DROP INDEX users_login;
DROP INDEX users_session_id;
ALTER TABLE users ADD CONSTRAINT users_login UNIQUE (login);
ALTER TABLE users ADD CONSTRAINT users_session_id UNIQUE (session_id);
COMMIT;