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,204 +1,204 @@
|
|
1
|
-
create table reference_types (
|
2
|
-
reference_type_id int not null auto_increment,
|
3
|
-
type_label varchar(50) default null,
|
4
|
-
abbreviation varchar(50) default null,
|
5
|
-
description varchar(50) default null,
|
6
|
-
primary key (reference_type_id)
|
7
|
-
);
|
8
|
-
|
9
|
-
create table reference_codes (
|
10
|
-
reference_type_id int not null,
|
11
|
-
reference_code int not null,
|
12
|
-
code_label varchar(50) default null,
|
13
|
-
abbreviation varchar(50) default null,
|
14
|
-
description varchar(50) default null,
|
15
|
-
primary key (reference_type_id, reference_code)
|
16
|
-
);
|
17
|
-
|
18
|
-
create table products (
|
19
|
-
id int not null auto_increment,
|
20
|
-
name varchar(50) default null,
|
21
|
-
primary key (id)
|
22
|
-
);
|
23
|
-
|
24
|
-
create table tariffs (
|
25
|
-
tariff_id int not null,
|
26
|
-
start_date date not null,
|
27
|
-
amount integer(11) default null,
|
28
|
-
created_at datetime,
|
29
|
-
updated_at datetime,
|
30
|
-
primary key (tariff_id, start_date)
|
31
|
-
);
|
32
|
-
|
33
|
-
create table product_tariffs (
|
34
|
-
product_id int not null,
|
35
|
-
tariff_id int not null,
|
36
|
-
tariff_start_date date not null,
|
37
|
-
primary key (product_id, tariff_id, tariff_start_date)
|
38
|
-
);
|
39
|
-
|
40
|
-
create table suburbs (
|
41
|
-
city_id int not null auto_increment,
|
42
|
-
suburb_id int not null,
|
43
|
-
name varchar(50) not null,
|
44
|
-
primary key (city_id, suburb_id)
|
45
|
-
);
|
46
|
-
|
47
|
-
create table streets (
|
48
|
-
id int not null auto_increment,
|
49
|
-
city_id int not null,
|
50
|
-
suburb_id int not null,
|
51
|
-
name varchar(50) not null,
|
52
|
-
primary key (id)
|
53
|
-
);
|
54
|
-
|
55
|
-
create table users (
|
56
|
-
id int not null auto_increment,
|
57
|
-
name varchar(50) not null,
|
58
|
-
primary key (id)
|
59
|
-
);
|
60
|
-
|
61
|
-
create table moderators (
|
62
|
-
id int not null,
|
63
|
-
primary key (id)
|
64
|
-
);
|
65
|
-
|
66
|
-
create table admins (
|
67
|
-
id int not null,
|
68
|
-
primary key (id)
|
69
|
-
);
|
70
|
-
|
71
|
-
create table articles (
|
72
|
-
id int not null auto_increment,
|
73
|
-
name varchar(50) not null,
|
74
|
-
primary key (id)
|
75
|
-
);
|
76
|
-
|
77
|
-
create table readings (
|
78
|
-
id int not null auto_increment,
|
79
|
-
user_id int not null,
|
80
|
-
article_id int not null,
|
81
|
-
rating int not null,
|
82
|
-
primary key (id)
|
83
|
-
);
|
84
|
-
|
85
|
-
create table `groups` (
|
86
|
-
id int not null auto_increment,
|
87
|
-
name varchar(50) not null,
|
88
|
-
primary key (id)
|
89
|
-
);
|
90
|
-
|
91
|
-
create table memberships (
|
92
|
-
user_id int not null,
|
93
|
-
group_id int not null,
|
94
|
-
primary key (user_id,group_id)
|
95
|
-
);
|
96
|
-
|
97
|
-
create table membership_statuses (
|
98
|
-
id int not null auto_increment,
|
99
|
-
user_id int not null,
|
100
|
-
group_id int not null,
|
101
|
-
status varchar(50) not null,
|
102
|
-
primary key (id)
|
103
|
-
);
|
104
|
-
|
105
|
-
create table departments (
|
106
|
-
id int not null auto_increment,
|
107
|
-
location_id int not null,
|
108
|
-
primary key (id, location_id)
|
109
|
-
);
|
110
|
-
|
111
|
-
create table employees (
|
112
|
-
id int not null auto_increment,
|
113
|
-
department_id int default null,
|
114
|
-
location_id int default null,
|
115
|
-
name varchar(50) default null,
|
116
|
-
primary key (id)
|
117
|
-
);
|
118
|
-
|
119
|
-
create table comments (
|
120
|
-
id int not null auto_increment,
|
121
|
-
article_id int not null,
|
122
|
-
person_id int not null,
|
123
|
-
person_type varchar(100) not null,
|
124
|
-
primary key (id)
|
125
|
-
);
|
126
|
-
|
127
|
-
create table restaurants (
|
128
|
-
franchise_id int not null,
|
129
|
-
store_id int not null,
|
130
|
-
name varchar(100),
|
131
|
-
lock_version int default 0,
|
132
|
-
primary key (franchise_id, store_id)
|
133
|
-
);
|
134
|
-
|
135
|
-
create table restaurants_suburbs (
|
136
|
-
franchise_id int not null,
|
137
|
-
store_id int not null,
|
138
|
-
city_id int default null,
|
139
|
-
suburb_id int default null
|
140
|
-
);
|
141
|
-
|
142
|
-
create table dorms (
|
143
|
-
id int not null auto_increment,
|
144
|
-
primary key(id)
|
145
|
-
);
|
146
|
-
|
147
|
-
create table rooms (
|
148
|
-
dorm_id int not null,
|
149
|
-
room_id int not null,
|
150
|
-
primary key (dorm_id, room_id)
|
151
|
-
);
|
152
|
-
|
153
|
-
create table room_attributes (
|
154
|
-
id int not null auto_increment,
|
155
|
-
name varchar(50),
|
156
|
-
primary key(id)
|
157
|
-
);
|
158
|
-
|
159
|
-
create table room_attribute_assignments (
|
160
|
-
dorm_id int not null,
|
161
|
-
room_id int not null,
|
162
|
-
room_attribute_id int not null
|
163
|
-
);
|
164
|
-
|
165
|
-
create table staff_rooms (
|
166
|
-
dorm_id int not null,
|
167
|
-
room_id int not null,
|
168
|
-
primary key (dorm_id, room_id)
|
169
|
-
);
|
170
|
-
|
171
|
-
create table staff_room_keys (
|
172
|
-
dorm_id int not null,
|
173
|
-
room_id int not null,
|
174
|
-
key_no varchar(50) not null,
|
175
|
-
primary key (dorm_id, room_id)
|
176
|
-
);
|
177
|
-
|
178
|
-
create table students (
|
179
|
-
id int not null auto_increment,
|
180
|
-
primary key(id)
|
181
|
-
);
|
182
|
-
|
183
|
-
create table room_assignments (
|
184
|
-
student_id int not null,
|
185
|
-
dorm_id int not null,
|
186
|
-
room_id int not null
|
187
|
-
);
|
188
|
-
|
189
|
-
create table capitols (
|
190
|
-
country varchar(100) not null,
|
191
|
-
city varchar(100) not null,
|
192
|
-
primary key (country, city)
|
193
|
-
);
|
194
|
-
|
195
|
-
create table products_restaurants (
|
196
|
-
product_id int not null,
|
197
|
-
franchise_id int default null,
|
198
|
-
store_id int default null
|
199
|
-
);
|
200
|
-
|
201
|
-
create table employees_groups (
|
202
|
-
employee_id int not null,
|
203
|
-
group_id int not null
|
1
|
+
create table reference_types (
|
2
|
+
reference_type_id int not null auto_increment,
|
3
|
+
type_label varchar(50) default null,
|
4
|
+
abbreviation varchar(50) default null,
|
5
|
+
description varchar(50) default null,
|
6
|
+
primary key (reference_type_id)
|
7
|
+
);
|
8
|
+
|
9
|
+
create table reference_codes (
|
10
|
+
reference_type_id int not null,
|
11
|
+
reference_code int not null,
|
12
|
+
code_label varchar(50) default null,
|
13
|
+
abbreviation varchar(50) default null,
|
14
|
+
description varchar(50) default null,
|
15
|
+
primary key (reference_type_id, reference_code)
|
16
|
+
);
|
17
|
+
|
18
|
+
create table products (
|
19
|
+
id int not null auto_increment,
|
20
|
+
name varchar(50) default null,
|
21
|
+
primary key (id)
|
22
|
+
);
|
23
|
+
|
24
|
+
create table tariffs (
|
25
|
+
tariff_id int not null,
|
26
|
+
start_date date not null,
|
27
|
+
amount integer(11) default null,
|
28
|
+
created_at datetime,
|
29
|
+
updated_at datetime,
|
30
|
+
primary key (tariff_id, start_date)
|
31
|
+
);
|
32
|
+
|
33
|
+
create table product_tariffs (
|
34
|
+
product_id int not null,
|
35
|
+
tariff_id int not null,
|
36
|
+
tariff_start_date date not null,
|
37
|
+
primary key (product_id, tariff_id, tariff_start_date)
|
38
|
+
);
|
39
|
+
|
40
|
+
create table suburbs (
|
41
|
+
city_id int not null auto_increment,
|
42
|
+
suburb_id int not null,
|
43
|
+
name varchar(50) not null,
|
44
|
+
primary key (city_id, suburb_id)
|
45
|
+
);
|
46
|
+
|
47
|
+
create table streets (
|
48
|
+
id int not null auto_increment,
|
49
|
+
city_id int not null,
|
50
|
+
suburb_id int not null,
|
51
|
+
name varchar(50) not null,
|
52
|
+
primary key (id)
|
53
|
+
);
|
54
|
+
|
55
|
+
create table users (
|
56
|
+
id int not null auto_increment,
|
57
|
+
name varchar(50) not null,
|
58
|
+
primary key (id)
|
59
|
+
);
|
60
|
+
|
61
|
+
create table moderators (
|
62
|
+
id int not null,
|
63
|
+
primary key (id)
|
64
|
+
);
|
65
|
+
|
66
|
+
create table admins (
|
67
|
+
id int not null,
|
68
|
+
primary key (id)
|
69
|
+
);
|
70
|
+
|
71
|
+
create table articles (
|
72
|
+
id int not null auto_increment,
|
73
|
+
name varchar(50) not null,
|
74
|
+
primary key (id)
|
75
|
+
);
|
76
|
+
|
77
|
+
create table readings (
|
78
|
+
id int not null auto_increment,
|
79
|
+
user_id int not null,
|
80
|
+
article_id int not null,
|
81
|
+
rating int not null,
|
82
|
+
primary key (id)
|
83
|
+
);
|
84
|
+
|
85
|
+
create table `groups` (
|
86
|
+
id int not null auto_increment,
|
87
|
+
name varchar(50) not null,
|
88
|
+
primary key (id)
|
89
|
+
);
|
90
|
+
|
91
|
+
create table memberships (
|
92
|
+
user_id int not null,
|
93
|
+
group_id int not null,
|
94
|
+
primary key (user_id,group_id)
|
95
|
+
);
|
96
|
+
|
97
|
+
create table membership_statuses (
|
98
|
+
id int not null auto_increment,
|
99
|
+
user_id int not null,
|
100
|
+
group_id int not null,
|
101
|
+
status varchar(50) not null,
|
102
|
+
primary key (id)
|
103
|
+
);
|
104
|
+
|
105
|
+
create table departments (
|
106
|
+
id int not null auto_increment,
|
107
|
+
location_id int not null,
|
108
|
+
primary key (id, location_id)
|
109
|
+
);
|
110
|
+
|
111
|
+
create table employees (
|
112
|
+
id int not null auto_increment,
|
113
|
+
department_id int default null,
|
114
|
+
location_id int default null,
|
115
|
+
name varchar(50) default null,
|
116
|
+
primary key (id)
|
117
|
+
);
|
118
|
+
|
119
|
+
create table comments (
|
120
|
+
id int not null auto_increment,
|
121
|
+
article_id int not null,
|
122
|
+
person_id int not null,
|
123
|
+
person_type varchar(100) not null,
|
124
|
+
primary key (id)
|
125
|
+
);
|
126
|
+
|
127
|
+
create table restaurants (
|
128
|
+
franchise_id int not null,
|
129
|
+
store_id int not null,
|
130
|
+
name varchar(100),
|
131
|
+
lock_version int default 0,
|
132
|
+
primary key (franchise_id, store_id)
|
133
|
+
);
|
134
|
+
|
135
|
+
create table restaurants_suburbs (
|
136
|
+
franchise_id int not null,
|
137
|
+
store_id int not null,
|
138
|
+
city_id int default null,
|
139
|
+
suburb_id int default null
|
140
|
+
);
|
141
|
+
|
142
|
+
create table dorms (
|
143
|
+
id int not null auto_increment,
|
144
|
+
primary key(id)
|
145
|
+
);
|
146
|
+
|
147
|
+
create table rooms (
|
148
|
+
dorm_id int not null,
|
149
|
+
room_id int not null,
|
150
|
+
primary key (dorm_id, room_id)
|
151
|
+
);
|
152
|
+
|
153
|
+
create table room_attributes (
|
154
|
+
id int not null auto_increment,
|
155
|
+
name varchar(50),
|
156
|
+
primary key(id)
|
157
|
+
);
|
158
|
+
|
159
|
+
create table room_attribute_assignments (
|
160
|
+
dorm_id int not null,
|
161
|
+
room_id int not null,
|
162
|
+
room_attribute_id int not null
|
163
|
+
);
|
164
|
+
|
165
|
+
create table staff_rooms (
|
166
|
+
dorm_id int not null,
|
167
|
+
room_id int not null,
|
168
|
+
primary key (dorm_id, room_id)
|
169
|
+
);
|
170
|
+
|
171
|
+
create table staff_room_keys (
|
172
|
+
dorm_id int not null,
|
173
|
+
room_id int not null,
|
174
|
+
key_no varchar(50) not null,
|
175
|
+
primary key (dorm_id, room_id)
|
176
|
+
);
|
177
|
+
|
178
|
+
create table students (
|
179
|
+
id int not null auto_increment,
|
180
|
+
primary key(id)
|
181
|
+
);
|
182
|
+
|
183
|
+
create table room_assignments (
|
184
|
+
student_id int not null,
|
185
|
+
dorm_id int not null,
|
186
|
+
room_id int not null
|
187
|
+
);
|
188
|
+
|
189
|
+
create table capitols (
|
190
|
+
country varchar(100) not null,
|
191
|
+
city varchar(100) not null,
|
192
|
+
primary key (country, city)
|
193
|
+
);
|
194
|
+
|
195
|
+
create table products_restaurants (
|
196
|
+
product_id int not null,
|
197
|
+
franchise_id int default null,
|
198
|
+
store_id int default null
|
199
|
+
);
|
200
|
+
|
201
|
+
create table employees_groups (
|
202
|
+
employee_id int not null,
|
203
|
+
group_id int not null
|
204
204
|
);
|
@@ -1,46 +1,46 @@
|
|
1
|
-
drop table reference_types;
|
2
|
-
drop sequence reference_types_seq;
|
3
|
-
drop table reference_codes;
|
4
|
-
drop table products;
|
5
|
-
drop sequence products_seq;
|
6
|
-
drop table tariffs;
|
7
|
-
drop table product_tariffs;
|
8
|
-
drop table suburbs;
|
9
|
-
drop sequence suburbs_city_id_seq;
|
10
|
-
drop table streets;
|
11
|
-
drop sequence streets_seq;
|
12
|
-
drop table users;
|
13
|
-
drop sequence users_seq;
|
14
|
-
drop table moderators;
|
15
|
-
drop table admins;
|
16
|
-
drop table articles;
|
17
|
-
drop sequence articles_seq;
|
18
|
-
drop table readings;
|
19
|
-
drop sequence readings_seq;
|
20
|
-
drop table groups;
|
21
|
-
drop sequence groups_seq;
|
22
|
-
drop table memberships;
|
23
|
-
drop table membership_statuses;
|
24
|
-
drop sequence membership_statuses_seq;
|
25
|
-
drop table departments;
|
26
|
-
drop sequence departments_seq;
|
27
|
-
drop table employees;
|
28
|
-
drop sequence employees_seq;
|
29
|
-
drop table comments;
|
30
|
-
drop sequence comments_seq;
|
31
|
-
drop table restaurants;
|
32
|
-
drop table restaurants_suburbs;
|
33
|
-
drop table dorms;
|
34
|
-
drop sequence dorms_seq;
|
35
|
-
drop table rooms;
|
36
|
-
drop table room_attributes;
|
37
|
-
drop sequence room_attributes_seq;
|
38
|
-
drop table room_attribute_assignments;
|
39
|
-
drop table room_assignments;
|
40
|
-
drop table staff_rooms;
|
41
|
-
drop table staff_room_keys;
|
42
|
-
drop table students;
|
43
|
-
drop sequence students_seq;
|
44
|
-
drop table capitols;
|
45
|
-
drop table products_restaurants;
|
1
|
+
drop table reference_types;
|
2
|
+
drop sequence reference_types_seq;
|
3
|
+
drop table reference_codes;
|
4
|
+
drop table products;
|
5
|
+
drop sequence products_seq;
|
6
|
+
drop table tariffs;
|
7
|
+
drop table product_tariffs;
|
8
|
+
drop table suburbs;
|
9
|
+
drop sequence suburbs_city_id_seq;
|
10
|
+
drop table streets;
|
11
|
+
drop sequence streets_seq;
|
12
|
+
drop table users;
|
13
|
+
drop sequence users_seq;
|
14
|
+
drop table moderators;
|
15
|
+
drop table admins;
|
16
|
+
drop table articles;
|
17
|
+
drop sequence articles_seq;
|
18
|
+
drop table readings;
|
19
|
+
drop sequence readings_seq;
|
20
|
+
drop table groups;
|
21
|
+
drop sequence groups_seq;
|
22
|
+
drop table memberships;
|
23
|
+
drop table membership_statuses;
|
24
|
+
drop sequence membership_statuses_seq;
|
25
|
+
drop table departments;
|
26
|
+
drop sequence departments_seq;
|
27
|
+
drop table employees;
|
28
|
+
drop sequence employees_seq;
|
29
|
+
drop table comments;
|
30
|
+
drop sequence comments_seq;
|
31
|
+
drop table restaurants;
|
32
|
+
drop table restaurants_suburbs;
|
33
|
+
drop table dorms;
|
34
|
+
drop sequence dorms_seq;
|
35
|
+
drop table rooms;
|
36
|
+
drop table room_attributes;
|
37
|
+
drop sequence room_attributes_seq;
|
38
|
+
drop table room_attribute_assignments;
|
39
|
+
drop table room_assignments;
|
40
|
+
drop table staff_rooms;
|
41
|
+
drop table staff_room_keys;
|
42
|
+
drop table students;
|
43
|
+
drop sequence students_seq;
|
44
|
+
drop table capitols;
|
45
|
+
drop table products_restaurants;
|
46
46
|
drop table employees_groups;
|