composite_primary_keys 14.0.9 → 14.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.rdoc +10 -0
- data/README.rdoc +182 -182
- data/Rakefile +37 -37
- data/lib/composite_primary_keys/associations/collection_association.rb +38 -38
- data/lib/composite_primary_keys/associations/preloader/association.rb +52 -52
- data/lib/composite_primary_keys/autosave_association.rb +60 -60
- data/lib/composite_primary_keys/composite_arrays.rb +88 -88
- data/lib/composite_primary_keys/composite_predicates.rb +121 -121
- data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +36 -36
- data/lib/composite_primary_keys/core.rb +71 -48
- data/lib/composite_primary_keys/persistence.rb +96 -96
- data/lib/composite_primary_keys/reflection.rb +93 -91
- data/lib/composite_primary_keys/relation/calculations.rb +110 -110
- data/lib/composite_primary_keys/relation/query_methods.rb +40 -40
- data/lib/composite_primary_keys/relation.rb +199 -199
- data/lib/composite_primary_keys/validations/uniqueness.rb +40 -40
- data/lib/composite_primary_keys/version.rb +1 -1
- data/lib/composite_primary_keys.rb +117 -117
- data/scripts/console.rb +48 -48
- data/tasks/databases/trilogy.rake +23 -23
- data/test/abstract_unit.rb +124 -124
- data/test/connections/databases.ci.yml +32 -32
- data/test/fixtures/admin.rb +4 -4
- data/test/fixtures/db_definitions/db2-create-tables.sql +146 -146
- data/test/fixtures/db_definitions/db2-drop-tables.sql +23 -23
- data/test/fixtures/db_definitions/mysql.sql +203 -203
- data/test/fixtures/db_definitions/oracle.drop.sql +45 -45
- data/test/fixtures/db_definitions/oracle.sql +220 -220
- data/test/fixtures/db_definitions/postgresql.sql +205 -205
- data/test/fixtures/db_definitions/sqlite.sql +190 -190
- data/test/fixtures/db_definitions/sqlserver.sql +199 -199
- data/test/fixtures/department.rb +20 -20
- data/test/fixtures/moderator.rb +4 -4
- data/test/fixtures/room.rb +14 -14
- data/test/fixtures/room_assignment.rb +18 -18
- data/test/fixtures/staff_room.rb +6 -6
- data/test/fixtures/staff_room_key.rb +6 -6
- data/test/fixtures/user.rb +14 -14
- data/test/test_associations.rb +403 -403
- data/test/test_composite_arrays.rb +44 -44
- data/test/test_equal.rb +55 -26
- data/test/test_has_one_through.rb +30 -30
- data/test/test_hash.rb +73 -0
- data/test/test_nested_attributes.rb +90 -90
- metadata +7 -8
@@ -1,221 +1,221 @@
|
|
1
|
-
create sequence reference_types_seq start with 1000;
|
2
|
-
|
3
|
-
create table reference_types (
|
4
|
-
reference_type_id number(11) primary key,
|
5
|
-
type_label varchar(50) default null,
|
6
|
-
abbreviation varchar(50) default null,
|
7
|
-
description varchar(50) default null
|
8
|
-
);
|
9
|
-
|
10
|
-
create table reference_codes (
|
11
|
-
reference_type_id number(11),
|
12
|
-
reference_code number(11),
|
13
|
-
code_label varchar(50) default null,
|
14
|
-
abbreviation varchar(50) default null,
|
15
|
-
description varchar(50) default null
|
16
|
-
);
|
17
|
-
|
18
|
-
create sequence products_seq start with 1000;
|
19
|
-
|
20
|
-
create table products (
|
21
|
-
id number(11) primary key,
|
22
|
-
name varchar(50) default null
|
23
|
-
);
|
24
|
-
|
25
|
-
create table tariffs (
|
26
|
-
tariff_id number(11),
|
27
|
-
start_date date,
|
28
|
-
amount number(11) default null,
|
29
|
-
created_at timestamp,
|
30
|
-
updated_at timestamp,
|
31
|
-
constraint tariffs_pk primary key (tariff_id, start_date)
|
32
|
-
);
|
33
|
-
|
34
|
-
create table product_tariffs (
|
35
|
-
product_id number(11),
|
36
|
-
tariff_id number(11),
|
37
|
-
tariff_start_date date,
|
38
|
-
constraint product_tariffs_pk primary key (product_id, tariff_id, tariff_start_date)
|
39
|
-
);
|
40
|
-
|
41
|
-
create sequence suburbs_city_id_seq start with 1000;
|
42
|
-
|
43
|
-
create table suburbs (
|
44
|
-
city_id number(11) default suburbs_city_id_seq.nextval not null,
|
45
|
-
suburb_id number(11) not null,
|
46
|
-
name varchar(50) not null,
|
47
|
-
constraint suburbs_pk primary key (city_id, suburb_id)
|
48
|
-
);
|
49
|
-
|
50
|
-
create sequence streets_seq start with 1000;
|
51
|
-
|
52
|
-
create table streets (
|
53
|
-
id number(11) primary key,
|
54
|
-
city_id number(11) not null,
|
55
|
-
suburb_id number(11) not null,
|
56
|
-
name varchar(50) not null
|
57
|
-
);
|
58
|
-
|
59
|
-
create sequence users_seq start with 1000;
|
60
|
-
|
61
|
-
create table users (
|
62
|
-
id number(11) primary key,
|
63
|
-
name varchar(50) not null
|
64
|
-
);
|
65
|
-
|
66
|
-
create table moderators (
|
67
|
-
id number(11) primary key
|
68
|
-
);
|
69
|
-
|
70
|
-
create table admins (
|
71
|
-
id number(11) primary key
|
72
|
-
);
|
73
|
-
|
74
|
-
create sequence articles_seq start with 1000;
|
75
|
-
|
76
|
-
create table articles (
|
77
|
-
id number(11) primary key,
|
78
|
-
name varchar(50) not null
|
79
|
-
);
|
80
|
-
|
81
|
-
create sequence readings_seq start with 1000;
|
82
|
-
|
83
|
-
create table readings (
|
84
|
-
id number(11) primary key,
|
85
|
-
user_id number(11) not null,
|
86
|
-
article_id number(11) not null,
|
87
|
-
rating number(11) not null
|
88
|
-
);
|
89
|
-
|
90
|
-
create sequence groups_seq start with 1000;
|
91
|
-
|
92
|
-
create table groups (
|
93
|
-
id number(11) primary key,
|
94
|
-
name varchar(50) not null
|
95
|
-
);
|
96
|
-
|
97
|
-
create table memberships (
|
98
|
-
user_id number(11) not null,
|
99
|
-
group_id number(11) not null,
|
100
|
-
constraint memberships_pk primary key (user_id, group_id)
|
101
|
-
);
|
102
|
-
|
103
|
-
create sequence membership_statuses_seq start with 1000;
|
104
|
-
|
105
|
-
create table membership_statuses (
|
106
|
-
id number(11) primary key,
|
107
|
-
user_id number(11) not null,
|
108
|
-
group_id number(11) not null,
|
109
|
-
status varchar(50) not null
|
110
|
-
);
|
111
|
-
|
112
|
-
create sequence departments_seq start with 1000;
|
113
|
-
|
114
|
-
create table departments (
|
115
|
-
id number(11) not null,
|
116
|
-
location_id number(11) not null,
|
117
|
-
constraint departments_pk primary key (id, location_id)
|
118
|
-
);
|
119
|
-
|
120
|
-
create sequence employees_seq start with 1000;
|
121
|
-
|
122
|
-
create table employees (
|
123
|
-
id number(11) not null primary key,
|
124
|
-
department_id number(11) default null,
|
125
|
-
location_id number(11) default null,
|
126
|
-
name varchar(50) not null
|
127
|
-
);
|
128
|
-
|
129
|
-
create sequence comments_seq start with 1000;
|
130
|
-
|
131
|
-
create table comments (
|
132
|
-
id number(11) not null primary key,
|
133
|
-
article_id number(11) not null,
|
134
|
-
person_id number(11) not null,
|
135
|
-
person_type varchar(100) not null
|
136
|
-
);
|
137
|
-
|
138
|
-
create table restaurants (
|
139
|
-
franchise_id number(11) not null,
|
140
|
-
store_id number(11) not null,
|
141
|
-
name varchar(100),
|
142
|
-
lock_version number(11) default 0,
|
143
|
-
constraint restaurants_pk primary key (franchise_id, store_id)
|
144
|
-
);
|
145
|
-
|
146
|
-
create table restaurants_suburbs (
|
147
|
-
franchise_id number(11) not null,
|
148
|
-
store_id number(11) not null,
|
149
|
-
city_id number(11) not null,
|
150
|
-
suburb_id number(11) not null
|
151
|
-
);
|
152
|
-
|
153
|
-
create sequence dorms_seq start with 1000;
|
154
|
-
|
155
|
-
create table dorms (
|
156
|
-
id number(11) not null,
|
157
|
-
constraint dorms_pk primary key (id)
|
158
|
-
);
|
159
|
-
|
160
|
-
create table rooms (
|
161
|
-
dorm_id number(11) not null,
|
162
|
-
room_id number(11) not null,
|
163
|
-
constraint rooms_pk primary key (dorm_id, room_id)
|
164
|
-
);
|
165
|
-
|
166
|
-
create sequence room_attributes_seq start with 1000;
|
167
|
-
|
168
|
-
create table room_attributes (
|
169
|
-
id number(11) not null,
|
170
|
-
name varchar(50),
|
171
|
-
constraint room_attributes_pk primary key (id)
|
172
|
-
);
|
173
|
-
|
174
|
-
create table room_attribute_assignments (
|
175
|
-
dorm_id number(11) not null,
|
176
|
-
room_id number(11) not null,
|
177
|
-
room_attribute_id number(11) not null
|
178
|
-
);
|
179
|
-
|
180
|
-
create table staff_rooms (
|
181
|
-
dorm_id number(11) not null,
|
182
|
-
room_id number(11) not null,
|
183
|
-
constraint staff_rooms_pk primary key (dorm_id, room_id)
|
184
|
-
);
|
185
|
-
|
186
|
-
create table staff_room_keys (
|
187
|
-
dorm_id number(11) not null,
|
188
|
-
room_id number(11) not null,
|
189
|
-
key_no varchar(50) not null,
|
190
|
-
constraint staff_room_keys_pk primary key (dorm_id, room_id)
|
191
|
-
);
|
192
|
-
|
193
|
-
create sequence students_seq start with 1000;
|
194
|
-
|
195
|
-
create table students (
|
196
|
-
id number(11) not null,
|
197
|
-
constraint students_pk primary key (id)
|
198
|
-
);
|
199
|
-
|
200
|
-
create table room_assignments (
|
201
|
-
student_id number(11) not null,
|
202
|
-
dorm_id number(11) not null,
|
203
|
-
room_id number(11) not null
|
204
|
-
);
|
205
|
-
|
206
|
-
create table capitols (
|
207
|
-
country varchar(100) not null,
|
208
|
-
city varchar(100) not null,
|
209
|
-
primary key (country, city)
|
210
|
-
);
|
211
|
-
|
212
|
-
create table products_restaurants (
|
213
|
-
product_id number(11) not null,
|
214
|
-
franchise_id number(11) not null,
|
215
|
-
store_id number(11) not null
|
216
|
-
);
|
217
|
-
|
218
|
-
create table employees_groups (
|
219
|
-
employee_id int not null,
|
220
|
-
group_id int not null
|
1
|
+
create sequence reference_types_seq start with 1000;
|
2
|
+
|
3
|
+
create table reference_types (
|
4
|
+
reference_type_id number(11) primary key,
|
5
|
+
type_label varchar(50) default null,
|
6
|
+
abbreviation varchar(50) default null,
|
7
|
+
description varchar(50) default null
|
8
|
+
);
|
9
|
+
|
10
|
+
create table reference_codes (
|
11
|
+
reference_type_id number(11),
|
12
|
+
reference_code number(11),
|
13
|
+
code_label varchar(50) default null,
|
14
|
+
abbreviation varchar(50) default null,
|
15
|
+
description varchar(50) default null
|
16
|
+
);
|
17
|
+
|
18
|
+
create sequence products_seq start with 1000;
|
19
|
+
|
20
|
+
create table products (
|
21
|
+
id number(11) primary key,
|
22
|
+
name varchar(50) default null
|
23
|
+
);
|
24
|
+
|
25
|
+
create table tariffs (
|
26
|
+
tariff_id number(11),
|
27
|
+
start_date date,
|
28
|
+
amount number(11) default null,
|
29
|
+
created_at timestamp,
|
30
|
+
updated_at timestamp,
|
31
|
+
constraint tariffs_pk primary key (tariff_id, start_date)
|
32
|
+
);
|
33
|
+
|
34
|
+
create table product_tariffs (
|
35
|
+
product_id number(11),
|
36
|
+
tariff_id number(11),
|
37
|
+
tariff_start_date date,
|
38
|
+
constraint product_tariffs_pk primary key (product_id, tariff_id, tariff_start_date)
|
39
|
+
);
|
40
|
+
|
41
|
+
create sequence suburbs_city_id_seq start with 1000;
|
42
|
+
|
43
|
+
create table suburbs (
|
44
|
+
city_id number(11) default suburbs_city_id_seq.nextval not null,
|
45
|
+
suburb_id number(11) not null,
|
46
|
+
name varchar(50) not null,
|
47
|
+
constraint suburbs_pk primary key (city_id, suburb_id)
|
48
|
+
);
|
49
|
+
|
50
|
+
create sequence streets_seq start with 1000;
|
51
|
+
|
52
|
+
create table streets (
|
53
|
+
id number(11) primary key,
|
54
|
+
city_id number(11) not null,
|
55
|
+
suburb_id number(11) not null,
|
56
|
+
name varchar(50) not null
|
57
|
+
);
|
58
|
+
|
59
|
+
create sequence users_seq start with 1000;
|
60
|
+
|
61
|
+
create table users (
|
62
|
+
id number(11) primary key,
|
63
|
+
name varchar(50) not null
|
64
|
+
);
|
65
|
+
|
66
|
+
create table moderators (
|
67
|
+
id number(11) primary key
|
68
|
+
);
|
69
|
+
|
70
|
+
create table admins (
|
71
|
+
id number(11) primary key
|
72
|
+
);
|
73
|
+
|
74
|
+
create sequence articles_seq start with 1000;
|
75
|
+
|
76
|
+
create table articles (
|
77
|
+
id number(11) primary key,
|
78
|
+
name varchar(50) not null
|
79
|
+
);
|
80
|
+
|
81
|
+
create sequence readings_seq start with 1000;
|
82
|
+
|
83
|
+
create table readings (
|
84
|
+
id number(11) primary key,
|
85
|
+
user_id number(11) not null,
|
86
|
+
article_id number(11) not null,
|
87
|
+
rating number(11) not null
|
88
|
+
);
|
89
|
+
|
90
|
+
create sequence groups_seq start with 1000;
|
91
|
+
|
92
|
+
create table groups (
|
93
|
+
id number(11) primary key,
|
94
|
+
name varchar(50) not null
|
95
|
+
);
|
96
|
+
|
97
|
+
create table memberships (
|
98
|
+
user_id number(11) not null,
|
99
|
+
group_id number(11) not null,
|
100
|
+
constraint memberships_pk primary key (user_id, group_id)
|
101
|
+
);
|
102
|
+
|
103
|
+
create sequence membership_statuses_seq start with 1000;
|
104
|
+
|
105
|
+
create table membership_statuses (
|
106
|
+
id number(11) primary key,
|
107
|
+
user_id number(11) not null,
|
108
|
+
group_id number(11) not null,
|
109
|
+
status varchar(50) not null
|
110
|
+
);
|
111
|
+
|
112
|
+
create sequence departments_seq start with 1000;
|
113
|
+
|
114
|
+
create table departments (
|
115
|
+
id number(11) not null,
|
116
|
+
location_id number(11) not null,
|
117
|
+
constraint departments_pk primary key (id, location_id)
|
118
|
+
);
|
119
|
+
|
120
|
+
create sequence employees_seq start with 1000;
|
121
|
+
|
122
|
+
create table employees (
|
123
|
+
id number(11) not null primary key,
|
124
|
+
department_id number(11) default null,
|
125
|
+
location_id number(11) default null,
|
126
|
+
name varchar(50) not null
|
127
|
+
);
|
128
|
+
|
129
|
+
create sequence comments_seq start with 1000;
|
130
|
+
|
131
|
+
create table comments (
|
132
|
+
id number(11) not null primary key,
|
133
|
+
article_id number(11) not null,
|
134
|
+
person_id number(11) not null,
|
135
|
+
person_type varchar(100) not null
|
136
|
+
);
|
137
|
+
|
138
|
+
create table restaurants (
|
139
|
+
franchise_id number(11) not null,
|
140
|
+
store_id number(11) not null,
|
141
|
+
name varchar(100),
|
142
|
+
lock_version number(11) default 0,
|
143
|
+
constraint restaurants_pk primary key (franchise_id, store_id)
|
144
|
+
);
|
145
|
+
|
146
|
+
create table restaurants_suburbs (
|
147
|
+
franchise_id number(11) not null,
|
148
|
+
store_id number(11) not null,
|
149
|
+
city_id number(11) not null,
|
150
|
+
suburb_id number(11) not null
|
151
|
+
);
|
152
|
+
|
153
|
+
create sequence dorms_seq start with 1000;
|
154
|
+
|
155
|
+
create table dorms (
|
156
|
+
id number(11) not null,
|
157
|
+
constraint dorms_pk primary key (id)
|
158
|
+
);
|
159
|
+
|
160
|
+
create table rooms (
|
161
|
+
dorm_id number(11) not null,
|
162
|
+
room_id number(11) not null,
|
163
|
+
constraint rooms_pk primary key (dorm_id, room_id)
|
164
|
+
);
|
165
|
+
|
166
|
+
create sequence room_attributes_seq start with 1000;
|
167
|
+
|
168
|
+
create table room_attributes (
|
169
|
+
id number(11) not null,
|
170
|
+
name varchar(50),
|
171
|
+
constraint room_attributes_pk primary key (id)
|
172
|
+
);
|
173
|
+
|
174
|
+
create table room_attribute_assignments (
|
175
|
+
dorm_id number(11) not null,
|
176
|
+
room_id number(11) not null,
|
177
|
+
room_attribute_id number(11) not null
|
178
|
+
);
|
179
|
+
|
180
|
+
create table staff_rooms (
|
181
|
+
dorm_id number(11) not null,
|
182
|
+
room_id number(11) not null,
|
183
|
+
constraint staff_rooms_pk primary key (dorm_id, room_id)
|
184
|
+
);
|
185
|
+
|
186
|
+
create table staff_room_keys (
|
187
|
+
dorm_id number(11) not null,
|
188
|
+
room_id number(11) not null,
|
189
|
+
key_no varchar(50) not null,
|
190
|
+
constraint staff_room_keys_pk primary key (dorm_id, room_id)
|
191
|
+
);
|
192
|
+
|
193
|
+
create sequence students_seq start with 1000;
|
194
|
+
|
195
|
+
create table students (
|
196
|
+
id number(11) not null,
|
197
|
+
constraint students_pk primary key (id)
|
198
|
+
);
|
199
|
+
|
200
|
+
create table room_assignments (
|
201
|
+
student_id number(11) not null,
|
202
|
+
dorm_id number(11) not null,
|
203
|
+
room_id number(11) not null
|
204
|
+
);
|
205
|
+
|
206
|
+
create table capitols (
|
207
|
+
country varchar(100) not null,
|
208
|
+
city varchar(100) not null,
|
209
|
+
primary key (country, city)
|
210
|
+
);
|
211
|
+
|
212
|
+
create table products_restaurants (
|
213
|
+
product_id number(11) not null,
|
214
|
+
franchise_id number(11) not null,
|
215
|
+
store_id number(11) not null
|
216
|
+
);
|
217
|
+
|
218
|
+
create table employees_groups (
|
219
|
+
employee_id int not null,
|
220
|
+
group_id int not null
|
221
221
|
);
|