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