composite_primary_keys 7.0.13 → 7.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +615 -608
- data/lib/composite_primary_keys.rb +110 -110
- data/lib/composite_primary_keys/associations/association.rb +23 -23
- data/lib/composite_primary_keys/associations/association_scope.rb +77 -77
- data/lib/composite_primary_keys/associations/has_and_belongs_to_many_association.rb +59 -59
- data/lib/composite_primary_keys/associations/has_many_association.rb +56 -56
- data/lib/composite_primary_keys/associations/join_dependency.rb +89 -89
- data/lib/composite_primary_keys/associations/join_dependency/join_part.rb +38 -38
- data/lib/composite_primary_keys/associations/preloader/association.rb +78 -78
- data/lib/composite_primary_keys/associations/preloader/has_and_belongs_to_many.rb +46 -46
- data/lib/composite_primary_keys/attribute_methods/dirty.rb +26 -26
- data/lib/composite_primary_keys/attribute_methods/read.rb +34 -34
- data/lib/composite_primary_keys/attribute_methods/write.rb +36 -36
- data/lib/composite_primary_keys/base.rb +0 -6
- data/lib/composite_primary_keys/composite_arrays.rb +30 -30
- data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +4 -2
- data/lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb +17 -0
- data/lib/composite_primary_keys/core.rb +47 -47
- data/lib/composite_primary_keys/persistence.rb +60 -60
- data/lib/composite_primary_keys/relation.rb +56 -56
- data/lib/composite_primary_keys/relation/calculations.rb +75 -65
- data/lib/composite_primary_keys/relation/finder_methods.rb +196 -196
- data/lib/composite_primary_keys/sanitization.rb +52 -52
- data/lib/composite_primary_keys/validations/uniqueness.rb +37 -39
- data/lib/composite_primary_keys/version.rb +8 -8
- data/tasks/databases/sqlserver.rake +40 -27
- data/test/connections/databases.example.yml +18 -18
- data/test/connections/native_sqlserver/connection.rb +14 -11
- data/test/fixtures/db_definitions/mysql.sql +208 -208
- data/test/fixtures/db_definitions/postgresql.sql +210 -210
- data/test/fixtures/db_definitions/sqlite.sql +197 -197
- data/test/fixtures/db_definitions/sqlserver.drop.sql +94 -91
- data/test/fixtures/db_definitions/sqlserver.sql +232 -226
- data/test/fixtures/employee.rb +5 -5
- data/test/test_associations.rb +275 -275
- data/test/test_attributes.rb +60 -60
- data/test/test_create.rb +112 -112
- data/test/test_delete.rb +152 -148
- data/test/test_delete_all.rb +21 -21
- data/test/test_enum.rb +20 -20
- data/test/test_equal.rb +1 -1
- data/test/test_tutorial_example.rb +21 -21
- metadata +3 -2
@@ -1,210 +1,210 @@
|
|
1
|
-
create table topics (
|
2
|
-
id serial not null,
|
3
|
-
name varchar(50) default null,
|
4
|
-
feed_size int default null,
|
5
|
-
primary key (id)
|
6
|
-
);
|
7
|
-
|
8
|
-
create table topic_sources (
|
9
|
-
topic_id int not null,
|
10
|
-
platform varchar(50) not null,
|
11
|
-
keywords varchar(50) default null,
|
12
|
-
primary key (topic_id,platform)
|
13
|
-
);
|
14
|
-
|
15
|
-
create table reference_types (
|
16
|
-
reference_type_id serial not null,
|
17
|
-
type_label varchar(50) default null,
|
18
|
-
abbreviation varchar(50) default null,
|
19
|
-
description varchar(50) default null,
|
20
|
-
primary key (reference_type_id)
|
21
|
-
);
|
22
|
-
|
23
|
-
create table reference_codes (
|
24
|
-
reference_type_id int,
|
25
|
-
reference_code int not null,
|
26
|
-
code_label varchar(50) default null,
|
27
|
-
abbreviation varchar(50) default null,
|
28
|
-
description varchar(50) default null,
|
29
|
-
primary key (reference_type_id, reference_code)
|
30
|
-
);
|
31
|
-
|
32
|
-
create table products (
|
33
|
-
id serial not null,
|
34
|
-
name varchar(50) default null,
|
35
|
-
primary key (id),
|
36
|
-
created_at timestamp without time zone NOT NULL,
|
37
|
-
updated_at timestamp without time zone NOT NULL
|
38
|
-
);
|
39
|
-
|
40
|
-
create table tariffs (
|
41
|
-
tariff_id int not null,
|
42
|
-
start_date date not null,
|
43
|
-
amount int default null,
|
44
|
-
primary key (tariff_id, start_date),
|
45
|
-
created_at timestamp without time zone NOT NULL,
|
46
|
-
updated_at timestamp without time zone NOT NULL
|
47
|
-
);
|
48
|
-
|
49
|
-
create table product_tariffs (
|
50
|
-
product_id int not null,
|
51
|
-
tariff_id int not null,
|
52
|
-
tariff_start_date date not null,
|
53
|
-
primary key (product_id, tariff_id, tariff_start_date)
|
54
|
-
);
|
55
|
-
|
56
|
-
create table suburbs (
|
57
|
-
city_id int not null,
|
58
|
-
suburb_id int not null,
|
59
|
-
name varchar(50) not null,
|
60
|
-
primary key (city_id, suburb_id)
|
61
|
-
);
|
62
|
-
|
63
|
-
create table streets (
|
64
|
-
id serial not null,
|
65
|
-
city_id int not null,
|
66
|
-
suburb_id int not null,
|
67
|
-
name varchar(50) not null,
|
68
|
-
primary key (id)
|
69
|
-
);
|
70
|
-
|
71
|
-
create table users (
|
72
|
-
id serial not null,
|
73
|
-
name varchar(50) not null,
|
74
|
-
primary key (id)
|
75
|
-
);
|
76
|
-
|
77
|
-
create table articles (
|
78
|
-
id serial not null,
|
79
|
-
name varchar(50) not null,
|
80
|
-
primary key (id)
|
81
|
-
);
|
82
|
-
|
83
|
-
create table readings (
|
84
|
-
id serial not null,
|
85
|
-
user_id int not null,
|
86
|
-
article_id int not null,
|
87
|
-
rating int not null,
|
88
|
-
primary key (id)
|
89
|
-
);
|
90
|
-
|
91
|
-
create table groups (
|
92
|
-
id serial not null,
|
93
|
-
name varchar(50) not null,
|
94
|
-
primary key (id)
|
95
|
-
);
|
96
|
-
|
97
|
-
create table memberships (
|
98
|
-
user_id int not null,
|
99
|
-
group_id int not null,
|
100
|
-
primary key (user_id, group_id)
|
101
|
-
);
|
102
|
-
|
103
|
-
create table membership_statuses (
|
104
|
-
id serial not null,
|
105
|
-
user_id int not null,
|
106
|
-
group_id int not null,
|
107
|
-
status varchar(50) not null,
|
108
|
-
primary key (id)
|
109
|
-
);
|
110
|
-
|
111
|
-
create table departments (
|
112
|
-
department_id int not null,
|
113
|
-
location_id int not null,
|
114
|
-
primary key (department_id, location_id)
|
115
|
-
);
|
116
|
-
|
117
|
-
create table employees (
|
118
|
-
id serial not null,
|
119
|
-
department_id int default null,
|
120
|
-
location_id int default null,
|
121
|
-
primary key (id)
|
122
|
-
);
|
123
|
-
|
124
|
-
create table comments (
|
125
|
-
id serial not null,
|
126
|
-
person_id int default null,
|
127
|
-
shown int default null,
|
128
|
-
person_type varchar(100) default null,
|
129
|
-
hack_id int default null,
|
130
|
-
primary key (id)
|
131
|
-
);
|
132
|
-
|
133
|
-
create table hacks (
|
134
|
-
id serial not null,
|
135
|
-
name varchar(50) not null,
|
136
|
-
primary key (id)
|
137
|
-
);
|
138
|
-
|
139
|
-
create table restaurants (
|
140
|
-
franchise_id int not null,
|
141
|
-
store_id int not null,
|
142
|
-
name varchar(100),
|
143
|
-
lock_version int default 0,
|
144
|
-
primary key (franchise_id, store_id)
|
145
|
-
);
|
146
|
-
|
147
|
-
create table restaurants_suburbs (
|
148
|
-
franchise_id int not null,
|
149
|
-
store_id int not null,
|
150
|
-
city_id int not null,
|
151
|
-
suburb_id int not null
|
152
|
-
);
|
153
|
-
|
154
|
-
create table dorms (
|
155
|
-
id serial not null,
|
156
|
-
primary key (id)
|
157
|
-
);
|
158
|
-
|
159
|
-
create table rooms (
|
160
|
-
dorm_id int not null,
|
161
|
-
room_id int not null,
|
162
|
-
primary key (dorm_id, room_id)
|
163
|
-
);
|
164
|
-
|
165
|
-
create table room_attributes (
|
166
|
-
id serial not null,
|
167
|
-
name varchar(50),
|
168
|
-
primary key (id)
|
169
|
-
);
|
170
|
-
|
171
|
-
create table room_attribute_assignments (
|
172
|
-
dorm_id int not null,
|
173
|
-
room_id int not null,
|
174
|
-
room_attribute_id int not null
|
175
|
-
);
|
176
|
-
|
177
|
-
create table students (
|
178
|
-
id serial not null,
|
179
|
-
primary key (id)
|
180
|
-
);
|
181
|
-
|
182
|
-
create table room_assignments (
|
183
|
-
student_id int not null,
|
184
|
-
dorm_id int not null,
|
185
|
-
room_id int not null
|
186
|
-
);
|
187
|
-
|
188
|
-
create table seats (
|
189
|
-
flight_number int not null,
|
190
|
-
seat int not null,
|
191
|
-
customer int,
|
192
|
-
primary key (flight_number, seat)
|
193
|
-
);
|
194
|
-
|
195
|
-
create table capitols (
|
196
|
-
country text not null,
|
197
|
-
city text not null,
|
198
|
-
primary key (country, city)
|
199
|
-
);
|
200
|
-
|
201
|
-
create table products_restaurants (
|
202
|
-
product_id int not null,
|
203
|
-
franchise_id int not null,
|
204
|
-
store_id int not null
|
205
|
-
);
|
206
|
-
|
207
|
-
create table employees_groups (
|
208
|
-
employee_id int not null,
|
209
|
-
group_id int not null
|
210
|
-
);
|
1
|
+
create table topics (
|
2
|
+
id serial not null,
|
3
|
+
name varchar(50) default null,
|
4
|
+
feed_size int default null,
|
5
|
+
primary key (id)
|
6
|
+
);
|
7
|
+
|
8
|
+
create table topic_sources (
|
9
|
+
topic_id int not null,
|
10
|
+
platform varchar(50) not null,
|
11
|
+
keywords varchar(50) default null,
|
12
|
+
primary key (topic_id,platform)
|
13
|
+
);
|
14
|
+
|
15
|
+
create table reference_types (
|
16
|
+
reference_type_id serial not null,
|
17
|
+
type_label varchar(50) default null,
|
18
|
+
abbreviation varchar(50) default null,
|
19
|
+
description varchar(50) default null,
|
20
|
+
primary key (reference_type_id)
|
21
|
+
);
|
22
|
+
|
23
|
+
create table reference_codes (
|
24
|
+
reference_type_id int,
|
25
|
+
reference_code int not null,
|
26
|
+
code_label varchar(50) default null,
|
27
|
+
abbreviation varchar(50) default null,
|
28
|
+
description varchar(50) default null,
|
29
|
+
primary key (reference_type_id, reference_code)
|
30
|
+
);
|
31
|
+
|
32
|
+
create table products (
|
33
|
+
id serial not null,
|
34
|
+
name varchar(50) default null,
|
35
|
+
primary key (id),
|
36
|
+
created_at timestamp without time zone NOT NULL,
|
37
|
+
updated_at timestamp without time zone NOT NULL
|
38
|
+
);
|
39
|
+
|
40
|
+
create table tariffs (
|
41
|
+
tariff_id int not null,
|
42
|
+
start_date date not null,
|
43
|
+
amount int default null,
|
44
|
+
primary key (tariff_id, start_date),
|
45
|
+
created_at timestamp without time zone NOT NULL,
|
46
|
+
updated_at timestamp without time zone NOT NULL
|
47
|
+
);
|
48
|
+
|
49
|
+
create table product_tariffs (
|
50
|
+
product_id int not null,
|
51
|
+
tariff_id int not null,
|
52
|
+
tariff_start_date date not null,
|
53
|
+
primary key (product_id, tariff_id, tariff_start_date)
|
54
|
+
);
|
55
|
+
|
56
|
+
create table suburbs (
|
57
|
+
city_id int not null,
|
58
|
+
suburb_id int not null,
|
59
|
+
name varchar(50) not null,
|
60
|
+
primary key (city_id, suburb_id)
|
61
|
+
);
|
62
|
+
|
63
|
+
create table streets (
|
64
|
+
id serial not null,
|
65
|
+
city_id int not null,
|
66
|
+
suburb_id int not null,
|
67
|
+
name varchar(50) not null,
|
68
|
+
primary key (id)
|
69
|
+
);
|
70
|
+
|
71
|
+
create table users (
|
72
|
+
id serial not null,
|
73
|
+
name varchar(50) not null,
|
74
|
+
primary key (id)
|
75
|
+
);
|
76
|
+
|
77
|
+
create table articles (
|
78
|
+
id serial not null,
|
79
|
+
name varchar(50) not null,
|
80
|
+
primary key (id)
|
81
|
+
);
|
82
|
+
|
83
|
+
create table readings (
|
84
|
+
id serial not null,
|
85
|
+
user_id int not null,
|
86
|
+
article_id int not null,
|
87
|
+
rating int not null,
|
88
|
+
primary key (id)
|
89
|
+
);
|
90
|
+
|
91
|
+
create table groups (
|
92
|
+
id serial not null,
|
93
|
+
name varchar(50) not null,
|
94
|
+
primary key (id)
|
95
|
+
);
|
96
|
+
|
97
|
+
create table memberships (
|
98
|
+
user_id int not null,
|
99
|
+
group_id int not null,
|
100
|
+
primary key (user_id, group_id)
|
101
|
+
);
|
102
|
+
|
103
|
+
create table membership_statuses (
|
104
|
+
id serial not null,
|
105
|
+
user_id int not null,
|
106
|
+
group_id int not null,
|
107
|
+
status varchar(50) not null,
|
108
|
+
primary key (id)
|
109
|
+
);
|
110
|
+
|
111
|
+
create table departments (
|
112
|
+
department_id int not null,
|
113
|
+
location_id int not null,
|
114
|
+
primary key (department_id, location_id)
|
115
|
+
);
|
116
|
+
|
117
|
+
create table employees (
|
118
|
+
id serial not null,
|
119
|
+
department_id int default null,
|
120
|
+
location_id int default null,
|
121
|
+
primary key (id)
|
122
|
+
);
|
123
|
+
|
124
|
+
create table comments (
|
125
|
+
id serial not null,
|
126
|
+
person_id int default null,
|
127
|
+
shown int default null,
|
128
|
+
person_type varchar(100) default null,
|
129
|
+
hack_id int default null,
|
130
|
+
primary key (id)
|
131
|
+
);
|
132
|
+
|
133
|
+
create table hacks (
|
134
|
+
id serial not null,
|
135
|
+
name varchar(50) not null,
|
136
|
+
primary key (id)
|
137
|
+
);
|
138
|
+
|
139
|
+
create table restaurants (
|
140
|
+
franchise_id int not null,
|
141
|
+
store_id int not null,
|
142
|
+
name varchar(100),
|
143
|
+
lock_version int default 0,
|
144
|
+
primary key (franchise_id, store_id)
|
145
|
+
);
|
146
|
+
|
147
|
+
create table restaurants_suburbs (
|
148
|
+
franchise_id int not null,
|
149
|
+
store_id int not null,
|
150
|
+
city_id int not null,
|
151
|
+
suburb_id int not null
|
152
|
+
);
|
153
|
+
|
154
|
+
create table dorms (
|
155
|
+
id serial not null,
|
156
|
+
primary key (id)
|
157
|
+
);
|
158
|
+
|
159
|
+
create table rooms (
|
160
|
+
dorm_id int not null,
|
161
|
+
room_id int not null,
|
162
|
+
primary key (dorm_id, room_id)
|
163
|
+
);
|
164
|
+
|
165
|
+
create table room_attributes (
|
166
|
+
id serial not null,
|
167
|
+
name varchar(50),
|
168
|
+
primary key (id)
|
169
|
+
);
|
170
|
+
|
171
|
+
create table room_attribute_assignments (
|
172
|
+
dorm_id int not null,
|
173
|
+
room_id int not null,
|
174
|
+
room_attribute_id int not null
|
175
|
+
);
|
176
|
+
|
177
|
+
create table students (
|
178
|
+
id serial not null,
|
179
|
+
primary key (id)
|
180
|
+
);
|
181
|
+
|
182
|
+
create table room_assignments (
|
183
|
+
student_id int not null,
|
184
|
+
dorm_id int not null,
|
185
|
+
room_id int not null
|
186
|
+
);
|
187
|
+
|
188
|
+
create table seats (
|
189
|
+
flight_number int not null,
|
190
|
+
seat int not null,
|
191
|
+
customer int,
|
192
|
+
primary key (flight_number, seat)
|
193
|
+
);
|
194
|
+
|
195
|
+
create table capitols (
|
196
|
+
country text not null,
|
197
|
+
city text not null,
|
198
|
+
primary key (country, city)
|
199
|
+
);
|
200
|
+
|
201
|
+
create table products_restaurants (
|
202
|
+
product_id int not null,
|
203
|
+
franchise_id int not null,
|
204
|
+
store_id int not null
|
205
|
+
);
|
206
|
+
|
207
|
+
create table employees_groups (
|
208
|
+
employee_id int not null,
|
209
|
+
group_id int not null
|
210
|
+
);
|
@@ -1,197 +1,197 @@
|
|
1
|
-
create table topics (
|
2
|
-
id int not null,
|
3
|
-
name varchar(50) default null,
|
4
|
-
feed_size int default null,
|
5
|
-
primary key (id)
|
6
|
-
);
|
7
|
-
|
8
|
-
create table topic_sources (
|
9
|
-
topic_id int not null,
|
10
|
-
platform varchar(50) not null,
|
11
|
-
keywords varchar(50) default null,
|
12
|
-
primary key (topic_id,platform)
|
13
|
-
);
|
14
|
-
|
15
|
-
create table reference_types (
|
16
|
-
reference_type_id integer primary key,
|
17
|
-
type_label varchar(50) default null,
|
18
|
-
abbreviation varchar(50) default null,
|
19
|
-
description varchar(50) default null
|
20
|
-
);
|
21
|
-
|
22
|
-
create table reference_codes (
|
23
|
-
reference_type_id int(11),
|
24
|
-
reference_code int(11) not null,
|
25
|
-
code_label varchar(50) default null,
|
26
|
-
abbreviation varchar(50) default null,
|
27
|
-
description varchar(50) default null,
|
28
|
-
primary key (reference_type_id, reference_code)
|
29
|
-
);
|
30
|
-
|
31
|
-
create table products (
|
32
|
-
id int(11) not null primary key,
|
33
|
-
name varchar(50) default null,
|
34
|
-
created_at TIMESTAMP,
|
35
|
-
updated_at TIMESTAMP
|
36
|
-
);
|
37
|
-
|
38
|
-
create table tariffs (
|
39
|
-
tariff_id int(11) not null,
|
40
|
-
start_date date not null,
|
41
|
-
amount integer(11) default null,
|
42
|
-
created_at TIMESTAMP,
|
43
|
-
updated_at TIMESTAMP,
|
44
|
-
primary key (tariff_id, start_date)
|
45
|
-
);
|
46
|
-
|
47
|
-
create table product_tariffs (
|
48
|
-
product_id int(11) not null,
|
49
|
-
tariff_id int(11) not null,
|
50
|
-
tariff_start_date date not null,
|
51
|
-
primary key (product_id, tariff_id, tariff_start_date)
|
52
|
-
);
|
53
|
-
|
54
|
-
create table suburbs (
|
55
|
-
city_id int(11) not null,
|
56
|
-
suburb_id int(11) not null,
|
57
|
-
name varchar(50) not null,
|
58
|
-
primary key (city_id, suburb_id)
|
59
|
-
);
|
60
|
-
|
61
|
-
create table streets (
|
62
|
-
id integer not null primary key autoincrement,
|
63
|
-
city_id int(11) not null,
|
64
|
-
suburb_id int(11) not null,
|
65
|
-
name varchar(50) not null
|
66
|
-
);
|
67
|
-
|
68
|
-
create table users (
|
69
|
-
id integer not null primary key autoincrement,
|
70
|
-
name varchar(50) not null
|
71
|
-
);
|
72
|
-
|
73
|
-
create table articles (
|
74
|
-
id integer not null primary key autoincrement,
|
75
|
-
name varchar(50) not null
|
76
|
-
);
|
77
|
-
|
78
|
-
create table readings (
|
79
|
-
id integer not null primary key autoincrement,
|
80
|
-
user_id int(11) not null,
|
81
|
-
article_id int(11) not null,
|
82
|
-
rating int(11) not null
|
83
|
-
);
|
84
|
-
|
85
|
-
create table groups (
|
86
|
-
id integer not null primary key autoincrement,
|
87
|
-
name varchar(50) not null
|
88
|
-
);
|
89
|
-
|
90
|
-
create table memberships (
|
91
|
-
user_id int not null,
|
92
|
-
group_id int not null,
|
93
|
-
primary key (user_id, group_id)
|
94
|
-
);
|
95
|
-
|
96
|
-
create table membership_statuses (
|
97
|
-
id integer not null primary key autoincrement,
|
98
|
-
user_id int not null,
|
99
|
-
group_id int not null,
|
100
|
-
status varchar(50) not null
|
101
|
-
);
|
102
|
-
|
103
|
-
create table departments (
|
104
|
-
department_id integer not null,
|
105
|
-
location_id integer not null,
|
106
|
-
primary key (department_id, location_id)
|
107
|
-
);
|
108
|
-
|
109
|
-
create table employees (
|
110
|
-
id integer not null primary key autoincrement,
|
111
|
-
department_id integer null,
|
112
|
-
location_id integer null
|
113
|
-
);
|
114
|
-
|
115
|
-
create table comments (
|
116
|
-
id integer not null primary key autoincrement,
|
117
|
-
person_id int null,
|
118
|
-
shown int null,
|
119
|
-
person_type varchar(100) null,
|
120
|
-
hack_id int null
|
121
|
-
);
|
122
|
-
|
123
|
-
create table hacks (
|
124
|
-
id integer not null primary key autoincrement,
|
125
|
-
name varchar(50) not null
|
126
|
-
);
|
127
|
-
|
128
|
-
create table restaurants (
|
129
|
-
franchise_id integer not null,
|
130
|
-
store_id integer not null,
|
131
|
-
name varchar(100),
|
132
|
-
lock_version integer default 0,
|
133
|
-
primary key (franchise_id, store_id)
|
134
|
-
);
|
135
|
-
|
136
|
-
create table restaurants_suburbs (
|
137
|
-
franchise_id integer not null,
|
138
|
-
store_id integer not null,
|
139
|
-
city_id integer not null,
|
140
|
-
suburb_id integer not null
|
141
|
-
);
|
142
|
-
|
143
|
-
create table dorms (
|
144
|
-
id integer not null primary key autoincrement
|
145
|
-
);
|
146
|
-
|
147
|
-
create table rooms (
|
148
|
-
dorm_id integer not null,
|
149
|
-
room_id integer not null,
|
150
|
-
primary key (dorm_id, room_id)
|
151
|
-
);
|
152
|
-
|
153
|
-
create table room_attributes (
|
154
|
-
id integer not null primary key autoincrement,
|
155
|
-
name varchar(50)
|
156
|
-
);
|
157
|
-
|
158
|
-
create table room_attribute_assignments (
|
159
|
-
dorm_id integer not null,
|
160
|
-
room_id integer not null,
|
161
|
-
room_attribute_id integer not null
|
162
|
-
);
|
163
|
-
|
164
|
-
create table students (
|
165
|
-
id integer not null primary key autoincrement
|
166
|
-
);
|
167
|
-
|
168
|
-
create table room_assignments (
|
169
|
-
student_id integer not null,
|
170
|
-
dorm_id integer not null,
|
171
|
-
room_id integer not null
|
172
|
-
);
|
173
|
-
|
174
|
-
create table seats (
|
175
|
-
flight_number integer not_null,
|
176
|
-
seat integer not_null,
|
177
|
-
customer integer,
|
178
|
-
primary key (flight_number, seat)
|
179
|
-
);
|
180
|
-
|
181
|
-
create table capitols (
|
182
|
-
country text not null,
|
183
|
-
city text not null,
|
184
|
-
primary key (country, city)
|
185
|
-
);
|
186
|
-
|
187
|
-
create table products_restaurants (
|
188
|
-
product_id integer not null,
|
189
|
-
franchise_id integer not null,
|
190
|
-
store_id integer not null
|
191
|
-
);
|
192
|
-
|
193
|
-
create table employees_groups (
|
194
|
-
employee_id integer not null,
|
195
|
-
group_id integer not null
|
196
|
-
);
|
197
|
-
|
1
|
+
create table topics (
|
2
|
+
id int not null,
|
3
|
+
name varchar(50) default null,
|
4
|
+
feed_size int default null,
|
5
|
+
primary key (id)
|
6
|
+
);
|
7
|
+
|
8
|
+
create table topic_sources (
|
9
|
+
topic_id int not null,
|
10
|
+
platform varchar(50) not null,
|
11
|
+
keywords varchar(50) default null,
|
12
|
+
primary key (topic_id,platform)
|
13
|
+
);
|
14
|
+
|
15
|
+
create table reference_types (
|
16
|
+
reference_type_id integer primary key,
|
17
|
+
type_label varchar(50) default null,
|
18
|
+
abbreviation varchar(50) default null,
|
19
|
+
description varchar(50) default null
|
20
|
+
);
|
21
|
+
|
22
|
+
create table reference_codes (
|
23
|
+
reference_type_id int(11),
|
24
|
+
reference_code int(11) not null,
|
25
|
+
code_label varchar(50) default null,
|
26
|
+
abbreviation varchar(50) default null,
|
27
|
+
description varchar(50) default null,
|
28
|
+
primary key (reference_type_id, reference_code)
|
29
|
+
);
|
30
|
+
|
31
|
+
create table products (
|
32
|
+
id int(11) not null primary key,
|
33
|
+
name varchar(50) default null,
|
34
|
+
created_at TIMESTAMP,
|
35
|
+
updated_at TIMESTAMP
|
36
|
+
);
|
37
|
+
|
38
|
+
create table tariffs (
|
39
|
+
tariff_id int(11) not null,
|
40
|
+
start_date date not null,
|
41
|
+
amount integer(11) default null,
|
42
|
+
created_at TIMESTAMP,
|
43
|
+
updated_at TIMESTAMP,
|
44
|
+
primary key (tariff_id, start_date)
|
45
|
+
);
|
46
|
+
|
47
|
+
create table product_tariffs (
|
48
|
+
product_id int(11) not null,
|
49
|
+
tariff_id int(11) not null,
|
50
|
+
tariff_start_date date not null,
|
51
|
+
primary key (product_id, tariff_id, tariff_start_date)
|
52
|
+
);
|
53
|
+
|
54
|
+
create table suburbs (
|
55
|
+
city_id int(11) not null,
|
56
|
+
suburb_id int(11) not null,
|
57
|
+
name varchar(50) not null,
|
58
|
+
primary key (city_id, suburb_id)
|
59
|
+
);
|
60
|
+
|
61
|
+
create table streets (
|
62
|
+
id integer not null primary key autoincrement,
|
63
|
+
city_id int(11) not null,
|
64
|
+
suburb_id int(11) not null,
|
65
|
+
name varchar(50) not null
|
66
|
+
);
|
67
|
+
|
68
|
+
create table users (
|
69
|
+
id integer not null primary key autoincrement,
|
70
|
+
name varchar(50) not null
|
71
|
+
);
|
72
|
+
|
73
|
+
create table articles (
|
74
|
+
id integer not null primary key autoincrement,
|
75
|
+
name varchar(50) not null
|
76
|
+
);
|
77
|
+
|
78
|
+
create table readings (
|
79
|
+
id integer not null primary key autoincrement,
|
80
|
+
user_id int(11) not null,
|
81
|
+
article_id int(11) not null,
|
82
|
+
rating int(11) not null
|
83
|
+
);
|
84
|
+
|
85
|
+
create table groups (
|
86
|
+
id integer not null primary key autoincrement,
|
87
|
+
name varchar(50) not null
|
88
|
+
);
|
89
|
+
|
90
|
+
create table memberships (
|
91
|
+
user_id int not null,
|
92
|
+
group_id int not null,
|
93
|
+
primary key (user_id, group_id)
|
94
|
+
);
|
95
|
+
|
96
|
+
create table membership_statuses (
|
97
|
+
id integer not null primary key autoincrement,
|
98
|
+
user_id int not null,
|
99
|
+
group_id int not null,
|
100
|
+
status varchar(50) not null
|
101
|
+
);
|
102
|
+
|
103
|
+
create table departments (
|
104
|
+
department_id integer not null,
|
105
|
+
location_id integer not null,
|
106
|
+
primary key (department_id, location_id)
|
107
|
+
);
|
108
|
+
|
109
|
+
create table employees (
|
110
|
+
id integer not null primary key autoincrement,
|
111
|
+
department_id integer null,
|
112
|
+
location_id integer null
|
113
|
+
);
|
114
|
+
|
115
|
+
create table comments (
|
116
|
+
id integer not null primary key autoincrement,
|
117
|
+
person_id int null,
|
118
|
+
shown int null,
|
119
|
+
person_type varchar(100) null,
|
120
|
+
hack_id int null
|
121
|
+
);
|
122
|
+
|
123
|
+
create table hacks (
|
124
|
+
id integer not null primary key autoincrement,
|
125
|
+
name varchar(50) not null
|
126
|
+
);
|
127
|
+
|
128
|
+
create table restaurants (
|
129
|
+
franchise_id integer not null,
|
130
|
+
store_id integer not null,
|
131
|
+
name varchar(100),
|
132
|
+
lock_version integer default 0,
|
133
|
+
primary key (franchise_id, store_id)
|
134
|
+
);
|
135
|
+
|
136
|
+
create table restaurants_suburbs (
|
137
|
+
franchise_id integer not null,
|
138
|
+
store_id integer not null,
|
139
|
+
city_id integer not null,
|
140
|
+
suburb_id integer not null
|
141
|
+
);
|
142
|
+
|
143
|
+
create table dorms (
|
144
|
+
id integer not null primary key autoincrement
|
145
|
+
);
|
146
|
+
|
147
|
+
create table rooms (
|
148
|
+
dorm_id integer not null,
|
149
|
+
room_id integer not null,
|
150
|
+
primary key (dorm_id, room_id)
|
151
|
+
);
|
152
|
+
|
153
|
+
create table room_attributes (
|
154
|
+
id integer not null primary key autoincrement,
|
155
|
+
name varchar(50)
|
156
|
+
);
|
157
|
+
|
158
|
+
create table room_attribute_assignments (
|
159
|
+
dorm_id integer not null,
|
160
|
+
room_id integer not null,
|
161
|
+
room_attribute_id integer not null
|
162
|
+
);
|
163
|
+
|
164
|
+
create table students (
|
165
|
+
id integer not null primary key autoincrement
|
166
|
+
);
|
167
|
+
|
168
|
+
create table room_assignments (
|
169
|
+
student_id integer not null,
|
170
|
+
dorm_id integer not null,
|
171
|
+
room_id integer not null
|
172
|
+
);
|
173
|
+
|
174
|
+
create table seats (
|
175
|
+
flight_number integer not_null,
|
176
|
+
seat integer not_null,
|
177
|
+
customer integer,
|
178
|
+
primary key (flight_number, seat)
|
179
|
+
);
|
180
|
+
|
181
|
+
create table capitols (
|
182
|
+
country text not null,
|
183
|
+
city text not null,
|
184
|
+
primary key (country, city)
|
185
|
+
);
|
186
|
+
|
187
|
+
create table products_restaurants (
|
188
|
+
product_id integer not null,
|
189
|
+
franchise_id integer not null,
|
190
|
+
store_id integer not null
|
191
|
+
);
|
192
|
+
|
193
|
+
create table employees_groups (
|
194
|
+
employee_id integer not null,
|
195
|
+
group_id integer not null
|
196
|
+
);
|
197
|
+
|