composite_primary_keys 11.0.0.rc1 → 11.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +763 -754
  3. data/Rakefile +37 -37
  4. data/lib/composite_primary_keys.rb +122 -121
  5. data/lib/composite_primary_keys/arel/sqlserver.rb +37 -37
  6. data/lib/composite_primary_keys/arel/to_sql.rb +32 -32
  7. data/lib/composite_primary_keys/associations/association.rb +23 -23
  8. data/lib/composite_primary_keys/associations/association_scope.rb +68 -68
  9. data/lib/composite_primary_keys/associations/collection_association.rb +31 -31
  10. data/lib/composite_primary_keys/associations/has_many_association.rb +34 -34
  11. data/lib/composite_primary_keys/associations/join_dependency.rb +102 -102
  12. data/lib/composite_primary_keys/associations/preloader/association.rb +117 -117
  13. data/lib/composite_primary_keys/attribute_methods.rb +9 -9
  14. data/lib/composite_primary_keys/attribute_methods/read.rb +27 -27
  15. data/lib/composite_primary_keys/attribute_methods/write.rb +44 -44
  16. data/lib/composite_primary_keys/autosave_association.rb +32 -32
  17. data/lib/composite_primary_keys/base.rb +130 -130
  18. data/lib/composite_primary_keys/composite_arrays.rb +51 -51
  19. data/lib/composite_primary_keys/composite_predicates.rb +69 -69
  20. data/lib/composite_primary_keys/composite_relation.rb +29 -48
  21. data/lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb +29 -22
  22. data/lib/composite_primary_keys/connection_adapters/postgresql/database_statements.rb +26 -26
  23. data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +22 -22
  24. data/lib/composite_primary_keys/core.rb +54 -54
  25. data/lib/composite_primary_keys/counter_cache.rb +28 -0
  26. data/lib/composite_primary_keys/fixtures.rb +26 -26
  27. data/lib/composite_primary_keys/locking/optimistic.rb +56 -56
  28. data/lib/composite_primary_keys/persistence.rb +112 -93
  29. data/lib/composite_primary_keys/reflection.rb +20 -20
  30. data/lib/composite_primary_keys/relation.rb +88 -88
  31. data/lib/composite_primary_keys/relation/calculations.rb +79 -79
  32. data/lib/composite_primary_keys/relation/finder_methods.rb +229 -229
  33. data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +20 -20
  34. data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
  35. data/lib/composite_primary_keys/relation/where_clause.rb +24 -24
  36. data/lib/composite_primary_keys/sanitization.rb +42 -42
  37. data/lib/composite_primary_keys/validations/uniqueness.rb +32 -32
  38. data/lib/composite_primary_keys/version.rb +8 -8
  39. data/scripts/console.rb +0 -0
  40. data/tasks/databases/mysql.rake +40 -40
  41. data/tasks/databases/oracle.rake +41 -41
  42. data/tasks/databases/postgresql.rake +38 -38
  43. data/tasks/databases/sqlite.rake +25 -25
  44. data/tasks/databases/sqlserver.rake +43 -43
  45. data/test/abstract_unit.rb +120 -120
  46. data/test/connections/connection_spec.rb +27 -27
  47. data/test/connections/databases.ci.yml +16 -16
  48. data/test/connections/databases.example.yml +40 -40
  49. data/test/connections/databases.yml +10 -0
  50. data/test/fixtures/article.rb +6 -6
  51. data/test/fixtures/comment.rb +7 -7
  52. data/test/fixtures/db_definitions/db2-create-tables.sql +126 -126
  53. data/test/fixtures/db_definitions/db2-drop-tables.sql +18 -18
  54. data/test/fixtures/db_definitions/mysql.sql +226 -226
  55. data/test/fixtures/db_definitions/oracle.drop.sql +49 -49
  56. data/test/fixtures/db_definitions/oracle.sql +246 -246
  57. data/test/fixtures/db_definitions/postgresql.sql +229 -229
  58. data/test/fixtures/db_definitions/sqlite.sql +214 -214
  59. data/test/fixtures/db_definitions/sqlserver.sql +211 -211
  60. data/test/fixtures/dorm.rb +2 -2
  61. data/test/fixtures/employee.rb +10 -10
  62. data/test/fixtures/employees.yml +18 -18
  63. data/test/fixtures/membership.rb +6 -6
  64. data/test/fixtures/membership_statuses.yml +16 -16
  65. data/test/fixtures/memberships.yml +10 -10
  66. data/test/fixtures/pk_called_id.rb +5 -5
  67. data/test/fixtures/pk_called_ids.yml +11 -11
  68. data/test/fixtures/product_tariffs.yml +14 -14
  69. data/test/fixtures/reference_code.rb +7 -7
  70. data/test/fixtures/reference_type.rb +12 -12
  71. data/test/fixtures/restaurants_suburb.rb +2 -2
  72. data/test/fixtures/salary.rb +5 -5
  73. data/test/fixtures/suburb.rb +5 -5
  74. data/test/fixtures/tariff.rb +5 -5
  75. data/test/fixtures/tariffs.yml +14 -14
  76. data/test/fixtures/topic.rb +5 -5
  77. data/test/fixtures/topic_source.rb +6 -6
  78. data/test/fixtures/topic_sources.yml +3 -3
  79. data/test/fixtures/topics.yml +8 -8
  80. data/test/fixtures/user.rb +10 -10
  81. data/test/fixtures/users.yml +10 -10
  82. data/test/test_associations.rb +345 -345
  83. data/test/test_attribute_methods.rb +63 -63
  84. data/test/test_attributes.rb +60 -60
  85. data/test/test_calculations.rb +42 -42
  86. data/test/test_callbacks.rb +99 -99
  87. data/test/test_counter_cache.rb +1 -1
  88. data/test/test_create.rb +164 -164
  89. data/test/test_delete.rb +167 -167
  90. data/test/test_dumpable.rb +15 -15
  91. data/test/test_enum.rb +21 -21
  92. data/test/test_equal.rb +26 -26
  93. data/test/test_find.rb +137 -137
  94. data/test/test_habtm.rb +141 -141
  95. data/test/test_ids.rb +113 -113
  96. data/test/test_nested_attributes.rb +124 -124
  97. data/test/test_optimistic.rb +18 -18
  98. data/test/test_polymorphic.rb +27 -27
  99. data/test/test_predicates.rb +59 -59
  100. data/test/test_preload.rb +94 -94
  101. data/test/test_santiago.rb +23 -23
  102. data/test/test_suite.rb +34 -34
  103. data/test/test_touch.rb +23 -23
  104. data/test/test_tutorial_example.rb +25 -25
  105. data/test/test_update.rb +76 -76
  106. metadata +29 -28
@@ -1,214 +1,214 @@
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 salaries (
116
- id integer not null primary key autoincrement,
117
- employee_id integer,
118
- location_id integer,
119
- year int not null,
120
- month int not null,
121
- value int default null
122
- );
123
-
124
- create table comments (
125
- id integer not null primary key autoincrement,
126
- person_id int null,
127
- shown int null,
128
- person_type varchar(100) null,
129
- hack_id int null
130
- );
131
-
132
- create table hacks (
133
- id integer not null primary key autoincrement,
134
- name varchar(50) not null
135
- );
136
-
137
- create table restaurants (
138
- franchise_id integer not null,
139
- store_id integer not null,
140
- name varchar(100),
141
- lock_version integer default 0,
142
- primary key (franchise_id, store_id)
143
- );
144
-
145
- create table restaurants_suburbs (
146
- franchise_id integer not null,
147
- store_id integer not null,
148
- city_id integer not null,
149
- suburb_id integer not null
150
- );
151
-
152
- create table dorms (
153
- id integer not null primary key autoincrement
154
- );
155
-
156
- create table rooms (
157
- dorm_id integer not null,
158
- room_id integer not null,
159
- primary key (dorm_id, room_id)
160
- );
161
-
162
- create table room_attributes (
163
- id integer not null primary key autoincrement,
164
- name varchar(50)
165
- );
166
-
167
- create table room_attribute_assignments (
168
- dorm_id integer not null,
169
- room_id integer not null,
170
- room_attribute_id integer not null
171
- );
172
-
173
- create table students (
174
- id integer not null primary key autoincrement
175
- );
176
-
177
- create table room_assignments (
178
- student_id integer not null,
179
- dorm_id integer not null,
180
- room_id integer not null
181
- );
182
-
183
- create table seats (
184
- flight_number integer not_null,
185
- seat integer not_null,
186
- customer integer,
187
- primary key (flight_number, seat)
188
- );
189
-
190
- create table capitols (
191
- country text not null,
192
- city text not null,
193
- primary key (country, city)
194
- );
195
-
196
- create table products_restaurants (
197
- product_id integer not null,
198
- franchise_id integer not null,
199
- store_id integer not null
200
- );
201
-
202
- create table employees_groups (
203
- employee_id integer not null,
204
- group_id integer not null
205
- );
206
-
207
- create table pk_called_ids (
208
- id integer not null,
209
- reference_code int not null,
210
- code_label varchar(50) default null,
211
- abbreviation varchar(50) default null,
212
- description varchar(50) default null,
213
- primary key (id, reference_code)
214
- );
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 salaries (
116
+ id integer not null primary key autoincrement,
117
+ employee_id integer,
118
+ location_id integer,
119
+ year int not null,
120
+ month int not null,
121
+ value int default null
122
+ );
123
+
124
+ create table comments (
125
+ id integer not null primary key autoincrement,
126
+ person_id int null,
127
+ shown int null,
128
+ person_type varchar(100) null,
129
+ hack_id int null
130
+ );
131
+
132
+ create table hacks (
133
+ id integer not null primary key autoincrement,
134
+ name varchar(50) not null
135
+ );
136
+
137
+ create table restaurants (
138
+ franchise_id integer not null,
139
+ store_id integer not null,
140
+ name varchar(100),
141
+ lock_version integer default 0,
142
+ primary key (franchise_id, store_id)
143
+ );
144
+
145
+ create table restaurants_suburbs (
146
+ franchise_id integer not null,
147
+ store_id integer not null,
148
+ city_id integer not null,
149
+ suburb_id integer not null
150
+ );
151
+
152
+ create table dorms (
153
+ id integer not null primary key autoincrement
154
+ );
155
+
156
+ create table rooms (
157
+ dorm_id integer not null,
158
+ room_id integer not null,
159
+ primary key (dorm_id, room_id)
160
+ );
161
+
162
+ create table room_attributes (
163
+ id integer not null primary key autoincrement,
164
+ name varchar(50)
165
+ );
166
+
167
+ create table room_attribute_assignments (
168
+ dorm_id integer not null,
169
+ room_id integer not null,
170
+ room_attribute_id integer not null
171
+ );
172
+
173
+ create table students (
174
+ id integer not null primary key autoincrement
175
+ );
176
+
177
+ create table room_assignments (
178
+ student_id integer not null,
179
+ dorm_id integer not null,
180
+ room_id integer not null
181
+ );
182
+
183
+ create table seats (
184
+ flight_number integer not_null,
185
+ seat integer not_null,
186
+ customer integer,
187
+ primary key (flight_number, seat)
188
+ );
189
+
190
+ create table capitols (
191
+ country text not null,
192
+ city text not null,
193
+ primary key (country, city)
194
+ );
195
+
196
+ create table products_restaurants (
197
+ product_id integer not null,
198
+ franchise_id integer not null,
199
+ store_id integer not null
200
+ );
201
+
202
+ create table employees_groups (
203
+ employee_id integer not null,
204
+ group_id integer not null
205
+ );
206
+
207
+ create table pk_called_ids (
208
+ id integer not null,
209
+ reference_code int not null,
210
+ code_label varchar(50) default null,
211
+ abbreviation varchar(50) default null,
212
+ description varchar(50) default null,
213
+ primary key (id, reference_code)
214
+ );
@@ -1,212 +1,212 @@
1
- USE [composite_primary_keys_unittest];
2
-
3
- CREATE TABLE topics (
4
- id [int] IDENTITY(1000,1) NOT NULL,
5
- name [varchar](50) default NULL,
6
- feed_size [int] default NULL
7
- );
8
-
9
- CREATE TABLE topic_sources (
10
- topic_id [int] NOT NULL,
11
- platform [varchar](50) NOT NULL,
12
- keywords [varchar](50) default NULL,
13
- );
14
-
15
- CREATE TABLE reference_types (
16
- reference_type_id [int] IDENTITY(1000,1) NOT NULL,
17
- type_label [varchar](50) NULL,
18
- abbreviation [varchar](50) NULL,
19
- description [varchar](50) NULL
20
- );
21
-
22
- CREATE TABLE reference_codes (
23
- reference_type_id [int],
24
- reference_code [int],
25
- code_label [varchar](50) NULL,
26
- abbreviation [varchar](50) NULL,
27
- description [varchar](50) NULL
28
- );
29
-
30
- CREATE TABLE products (
31
- id [int] IDENTITY(1000,1) NOT NULL,
32
- name [varchar](50) NULL
33
- );
34
-
35
- CREATE TABLE tariffs (
36
- [tariff_id] [int],
37
- [start_date] [date],
38
- [amount] [int] NULL,
39
- [created_at] [datetimeoffset](7) NOT NULL,
40
- [updated_at] [datetimeoffset](7) NOT NULL
41
- CONSTRAINT [tariffs_pk] PRIMARY KEY
42
- ( [tariff_id], [start_date] )
43
- );
44
-
45
- CREATE TABLE product_tariffs (
46
- [product_id] [int],
47
- [tariff_id] [int],
48
- [tariff_start_date] [date]
49
- CONSTRAINT [product_tariffs_pk] PRIMARY KEY
50
- ( [product_id], [tariff_id], [tariff_start_date] )
51
- );
52
-
53
- CREATE TABLE suburbs (
54
- city_id [int],
55
- suburb_id [int],
56
- name varchar(50) not null,
57
- CONSTRAINT [suburbs_pk] PRIMARY KEY
58
- ( [city_id], [suburb_id] )
59
- );
60
-
61
- CREATE TABLE streets (
62
- id [int] IDENTITY(1000,1) NOT NULL,
63
- city_id [int] NOT NULL,
64
- suburb_id [int] NOT NULL,
65
- name [varchar](50) NOT NULL
66
- );
67
-
68
- CREATE TABLE users (
69
- id [int] IDENTITY(1000,1) NOT NULL,
70
- name varchar(50) NOT NULL
71
- );
72
-
73
- CREATE TABLE articles (
74
- id [int] IDENTITY(1000,1) NOT NULL,
75
- name varchar(50) NOT NULL
76
- );
77
-
78
- CREATE TABLE readings (
79
- id [int] PRIMARY KEY,
80
- user_id [int] NOT NULL,
81
- article_id [int] NOT NULL,
82
- rating [int] NOT NULL
83
- );
84
-
85
- CREATE TABLE groups (
86
- id [int] IDENTITY(1000,1) NOT NULL,
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
- CONSTRAINT [memberships_pk] PRIMARY KEY
94
- ( [user_id], [group_id] )
95
- );
96
-
97
- CREATE TABLE membership_statuses (
98
- id [int] IDENTITY(1,1) NOT NULL,
99
- user_id [int] not null,
100
- group_id [int] not null,
101
- status varchar(50) not null
102
- );
103
-
104
- CREATE TABLE departments (
105
- department_id [int] NOT NULL,
106
- location_id [int] NOT NULL
107
- CONSTRAINT [departments_pk] PRIMARY KEY
108
- ( [department_id], [location_id] )
109
- );
110
-
111
- CREATE TABLE employees (
112
- id [int] IDENTITY(1000,1) NOT NULL,
113
- department_id [int] NULL,
114
- location_id [int] NULL
115
- );
116
-
117
- CREATE TABLE comments (
118
- id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
119
- person_id [int] NULL,
120
- shown [int] NULL,
121
- person_type varchar(100) NULL,
122
- hack_id [int] NULL
123
- );
124
-
125
- CREATE TABLE hacks (
126
- id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
127
- name [varchar](50) NOT NULL
128
- );
129
-
130
- CREATE TABLE restaurants (
131
- franchise_id [int] NOT NULL,
132
- store_id [int] NOT NULL,
133
- name [varchar](100),
134
- lock_version [int] DEFAULT 0
135
- CONSTRAINT [restaurants_pk] PRIMARY KEY CLUSTERED
136
- ( [franchise_id], [store_id] )
137
- );
138
-
139
- CREATE TABLE restaurants_suburbs (
140
- franchise_id [int] NOT NULL,
141
- store_id [int] NOT NULL,
142
- city_id [int] NOT NULL,
143
- suburb_id [int] NOT NULL
144
- );
145
-
146
- CREATE TABLE dorms (
147
- id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL
148
- );
149
-
150
- CREATE TABLE rooms (
151
- dorm_id [int] NOT NULL,
152
- room_id [int] NOT NULL,
153
- CONSTRAINT [rooms_pk] PRIMARY KEY CLUSTERED
154
- ( [dorm_id], [room_id] )
155
- );
156
-
157
- CREATE TABLE room_attributes (
158
- id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
159
- name [varchar](50)
160
- );
161
-
162
- CREATE TABLE room_attribute_assignments (
163
- dorm_id [int] NOT NULL,
164
- room_id [int] NOT NULL,
165
- room_attribute_id [int] NOT NULL
166
- );
167
-
168
- CREATE TABLE students (
169
- id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL
170
- );
171
-
172
- CREATE TABLE room_assignments (
173
- student_id [int] NOT NULL,
174
- dorm_id [int] NOT NULL,
175
- room_id [int] NOT NULL
176
- );
177
-
178
- CREATE TABLE seats (
179
- flight_number [int] NOT NULL,
180
- seat [int] NOT NULL,
181
- customer [int]
182
- CONSTRAINT [seats_pk] PRIMARY KEY
183
- ( [flight_number], [seat] )
184
- );
185
-
186
- CREATE TABLE capitols (
187
- country varchar(450) NOT NULL,
188
- city varchar(450) NOT NULL
189
- CONSTRAINT [capitols_pk] PRIMARY KEY
190
- ( [country], [city] )
191
- );
192
-
193
- CREATE TABLE products_restaurants (
194
- product_id [int] NOT NULL,
195
- franchise_id [int] NOT NULL,
196
- store_id [int] NOT NULL
197
- );
198
-
199
- CREATE TABLE employees_groups (
200
- employee_id [int] not null,
201
- group_id [int] not null
202
- );
203
-
204
- CREATE TABLE pk_called_ids (
205
- id [int] IDENTITY(1000,1) NOT NULL,
206
- reference_code [int] not null,
207
- code_label [varchar](50) default null,
208
- abbreviation [varchar](50) default null,
209
- description [varchar](50) default null
210
- CONSTRAINT [pk_called_ids_pk] PRIMARY KEY
211
- ( [id], [reference_code] )
1
+ USE [composite_primary_keys_unittest];
2
+
3
+ CREATE TABLE topics (
4
+ id [int] IDENTITY(1000,1) NOT NULL,
5
+ name [varchar](50) default NULL,
6
+ feed_size [int] default NULL
7
+ );
8
+
9
+ CREATE TABLE topic_sources (
10
+ topic_id [int] NOT NULL,
11
+ platform [varchar](50) NOT NULL,
12
+ keywords [varchar](50) default NULL,
13
+ );
14
+
15
+ CREATE TABLE reference_types (
16
+ reference_type_id [int] IDENTITY(1000,1) NOT NULL,
17
+ type_label [varchar](50) NULL,
18
+ abbreviation [varchar](50) NULL,
19
+ description [varchar](50) NULL
20
+ );
21
+
22
+ CREATE TABLE reference_codes (
23
+ reference_type_id [int],
24
+ reference_code [int],
25
+ code_label [varchar](50) NULL,
26
+ abbreviation [varchar](50) NULL,
27
+ description [varchar](50) NULL
28
+ );
29
+
30
+ CREATE TABLE products (
31
+ id [int] IDENTITY(1000,1) NOT NULL,
32
+ name [varchar](50) NULL
33
+ );
34
+
35
+ CREATE TABLE tariffs (
36
+ [tariff_id] [int],
37
+ [start_date] [date],
38
+ [amount] [int] NULL,
39
+ [created_at] [datetimeoffset](7) NOT NULL,
40
+ [updated_at] [datetimeoffset](7) NOT NULL
41
+ CONSTRAINT [tariffs_pk] PRIMARY KEY
42
+ ( [tariff_id], [start_date] )
43
+ );
44
+
45
+ CREATE TABLE product_tariffs (
46
+ [product_id] [int],
47
+ [tariff_id] [int],
48
+ [tariff_start_date] [date]
49
+ CONSTRAINT [product_tariffs_pk] PRIMARY KEY
50
+ ( [product_id], [tariff_id], [tariff_start_date] )
51
+ );
52
+
53
+ CREATE TABLE suburbs (
54
+ city_id [int],
55
+ suburb_id [int],
56
+ name varchar(50) not null,
57
+ CONSTRAINT [suburbs_pk] PRIMARY KEY
58
+ ( [city_id], [suburb_id] )
59
+ );
60
+
61
+ CREATE TABLE streets (
62
+ id [int] IDENTITY(1000,1) NOT NULL,
63
+ city_id [int] NOT NULL,
64
+ suburb_id [int] NOT NULL,
65
+ name [varchar](50) NOT NULL
66
+ );
67
+
68
+ CREATE TABLE users (
69
+ id [int] IDENTITY(1000,1) NOT NULL,
70
+ name varchar(50) NOT NULL
71
+ );
72
+
73
+ CREATE TABLE articles (
74
+ id [int] IDENTITY(1000,1) NOT NULL,
75
+ name varchar(50) NOT NULL
76
+ );
77
+
78
+ CREATE TABLE readings (
79
+ id [int] PRIMARY KEY,
80
+ user_id [int] NOT NULL,
81
+ article_id [int] NOT NULL,
82
+ rating [int] NOT NULL
83
+ );
84
+
85
+ CREATE TABLE groups (
86
+ id [int] IDENTITY(1000,1) NOT NULL,
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
+ CONSTRAINT [memberships_pk] PRIMARY KEY
94
+ ( [user_id], [group_id] )
95
+ );
96
+
97
+ CREATE TABLE membership_statuses (
98
+ id [int] IDENTITY(1,1) NOT NULL,
99
+ user_id [int] not null,
100
+ group_id [int] not null,
101
+ status varchar(50) not null
102
+ );
103
+
104
+ CREATE TABLE departments (
105
+ department_id [int] NOT NULL,
106
+ location_id [int] NOT NULL
107
+ CONSTRAINT [departments_pk] PRIMARY KEY
108
+ ( [department_id], [location_id] )
109
+ );
110
+
111
+ CREATE TABLE employees (
112
+ id [int] IDENTITY(1000,1) NOT NULL,
113
+ department_id [int] NULL,
114
+ location_id [int] NULL
115
+ );
116
+
117
+ CREATE TABLE comments (
118
+ id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
119
+ person_id [int] NULL,
120
+ shown [int] NULL,
121
+ person_type varchar(100) NULL,
122
+ hack_id [int] NULL
123
+ );
124
+
125
+ CREATE TABLE hacks (
126
+ id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
127
+ name [varchar](50) NOT NULL
128
+ );
129
+
130
+ CREATE TABLE restaurants (
131
+ franchise_id [int] NOT NULL,
132
+ store_id [int] NOT NULL,
133
+ name [varchar](100),
134
+ lock_version [int] DEFAULT 0
135
+ CONSTRAINT [restaurants_pk] PRIMARY KEY CLUSTERED
136
+ ( [franchise_id], [store_id] )
137
+ );
138
+
139
+ CREATE TABLE restaurants_suburbs (
140
+ franchise_id [int] NOT NULL,
141
+ store_id [int] NOT NULL,
142
+ city_id [int] NOT NULL,
143
+ suburb_id [int] NOT NULL
144
+ );
145
+
146
+ CREATE TABLE dorms (
147
+ id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL
148
+ );
149
+
150
+ CREATE TABLE rooms (
151
+ dorm_id [int] NOT NULL,
152
+ room_id [int] NOT NULL,
153
+ CONSTRAINT [rooms_pk] PRIMARY KEY CLUSTERED
154
+ ( [dorm_id], [room_id] )
155
+ );
156
+
157
+ CREATE TABLE room_attributes (
158
+ id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL,
159
+ name [varchar](50)
160
+ );
161
+
162
+ CREATE TABLE room_attribute_assignments (
163
+ dorm_id [int] NOT NULL,
164
+ room_id [int] NOT NULL,
165
+ room_attribute_id [int] NOT NULL
166
+ );
167
+
168
+ CREATE TABLE students (
169
+ id [int] IDENTITY(1000,1) PRIMARY KEY NOT NULL
170
+ );
171
+
172
+ CREATE TABLE room_assignments (
173
+ student_id [int] NOT NULL,
174
+ dorm_id [int] NOT NULL,
175
+ room_id [int] NOT NULL
176
+ );
177
+
178
+ CREATE TABLE seats (
179
+ flight_number [int] NOT NULL,
180
+ seat [int] NOT NULL,
181
+ customer [int]
182
+ CONSTRAINT [seats_pk] PRIMARY KEY
183
+ ( [flight_number], [seat] )
184
+ );
185
+
186
+ CREATE TABLE capitols (
187
+ country varchar(450) NOT NULL,
188
+ city varchar(450) NOT NULL
189
+ CONSTRAINT [capitols_pk] PRIMARY KEY
190
+ ( [country], [city] )
191
+ );
192
+
193
+ CREATE TABLE products_restaurants (
194
+ product_id [int] NOT NULL,
195
+ franchise_id [int] NOT NULL,
196
+ store_id [int] NOT NULL
197
+ );
198
+
199
+ CREATE TABLE employees_groups (
200
+ employee_id [int] not null,
201
+ group_id [int] not null
202
+ );
203
+
204
+ CREATE TABLE pk_called_ids (
205
+ id [int] IDENTITY(1000,1) NOT NULL,
206
+ reference_code [int] not null,
207
+ code_label [varchar](50) default null,
208
+ abbreviation [varchar](50) default null,
209
+ description [varchar](50) default null
210
+ CONSTRAINT [pk_called_ids_pk] PRIMARY KEY
211
+ ( [id], [reference_code] )
212
212
  );