ensured_schema 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile.lock +23 -0
- data/Rakefile +19 -0
- data/ensured_schema.gemspec +4 -0
- data/lib/ensured_schema/column.rb +9 -0
- data/lib/ensured_schema/ensured_table.rb +53 -0
- data/lib/ensured_schema/mysql_column.rb +17 -0
- data/lib/ensured_schema/schema.rb +7 -0
- data/lib/ensured_schema/schema_statements.rb +69 -0
- data/lib/ensured_schema/version.rb +1 -1
- data/lib/ensured_schema.rb +5 -155
- data/test/cases/ensured_schema_test.rb +206 -0
- data/test/cases/helper.rb +70 -0
- data/test/cases/migration_test.rb +1523 -0
- data/test/cases/repair_helper.rb +50 -0
- data/test/config.rb +5 -0
- data/test/connections/native_mysql/connection.rb +25 -0
- data/test/migrations/broken/100_migration_that_raises_exception.rb +10 -0
- data/test/migrations/decimal/1_give_me_big_numbers.rb +15 -0
- data/test/migrations/duplicate/1_people_have_last_names.rb +9 -0
- data/test/migrations/duplicate/2_we_need_reminders.rb +12 -0
- data/test/migrations/duplicate/3_foo.rb +7 -0
- data/test/migrations/duplicate/3_innocent_jointable.rb +12 -0
- data/test/migrations/duplicate_names/20080507052938_chunky.rb +7 -0
- data/test/migrations/duplicate_names/20080507053028_chunky.rb +7 -0
- data/test/migrations/interleaved/pass_1/3_innocent_jointable.rb +12 -0
- data/test/migrations/interleaved/pass_2/1_people_have_last_names.rb +9 -0
- data/test/migrations/interleaved/pass_2/3_innocent_jointable.rb +12 -0
- data/test/migrations/interleaved/pass_3/1_people_have_last_names.rb +9 -0
- data/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb +8 -0
- data/test/migrations/interleaved/pass_3/3_innocent_jointable.rb +12 -0
- data/test/migrations/missing/1000_people_have_middle_names.rb +9 -0
- data/test/migrations/missing/1_people_have_last_names.rb +9 -0
- data/test/migrations/missing/3_we_need_reminders.rb +12 -0
- data/test/migrations/missing/4_innocent_jointable.rb +12 -0
- data/test/migrations/valid/1_people_have_last_names.rb +9 -0
- data/test/migrations/valid/2_we_need_reminders.rb +12 -0
- data/test/migrations/valid/3_innocent_jointable.rb +12 -0
- data/test/models/author.rb +146 -0
- data/test/models/auto_id.rb +4 -0
- data/test/models/binary.rb +2 -0
- data/test/models/bird.rb +3 -0
- data/test/models/book.rb +4 -0
- data/test/models/categorization.rb +5 -0
- data/test/models/category.rb +34 -0
- data/test/models/citation.rb +6 -0
- data/test/models/club.rb +13 -0
- data/test/models/column_name.rb +3 -0
- data/test/models/comment.rb +29 -0
- data/test/models/company.rb +171 -0
- data/test/models/company_in_module.rb +61 -0
- data/test/models/computer.rb +3 -0
- data/test/models/contact.rb +16 -0
- data/test/models/contract.rb +5 -0
- data/test/models/course.rb +3 -0
- data/test/models/customer.rb +73 -0
- data/test/models/default.rb +2 -0
- data/test/models/developer.rb +101 -0
- data/test/models/edge.rb +5 -0
- data/test/models/entrant.rb +3 -0
- data/test/models/essay.rb +3 -0
- data/test/models/event.rb +3 -0
- data/test/models/guid.rb +2 -0
- data/test/models/item.rb +7 -0
- data/test/models/job.rb +5 -0
- data/test/models/joke.rb +3 -0
- data/test/models/keyboard.rb +3 -0
- data/test/models/legacy_thing.rb +3 -0
- data/test/models/matey.rb +4 -0
- data/test/models/member.rb +12 -0
- data/test/models/member_detail.rb +5 -0
- data/test/models/member_type.rb +3 -0
- data/test/models/membership.rb +9 -0
- data/test/models/minimalistic.rb +2 -0
- data/test/models/mixed_case_monkey.rb +3 -0
- data/test/models/movie.rb +5 -0
- data/test/models/order.rb +4 -0
- data/test/models/organization.rb +6 -0
- data/test/models/owner.rb +5 -0
- data/test/models/parrot.rb +16 -0
- data/test/models/person.rb +16 -0
- data/test/models/pet.rb +5 -0
- data/test/models/pirate.rb +70 -0
- data/test/models/post.rb +100 -0
- data/test/models/price_estimate.rb +3 -0
- data/test/models/project.rb +30 -0
- data/test/models/reader.rb +4 -0
- data/test/models/reference.rb +4 -0
- data/test/models/reply.rb +46 -0
- data/test/models/ship.rb +10 -0
- data/test/models/ship_part.rb +5 -0
- data/test/models/sponsor.rb +4 -0
- data/test/models/subject.rb +4 -0
- data/test/models/subscriber.rb +8 -0
- data/test/models/subscription.rb +4 -0
- data/test/models/tag.rb +7 -0
- data/test/models/tagging.rb +10 -0
- data/test/models/task.rb +3 -0
- data/test/models/topic.rb +80 -0
- data/test/models/toy.rb +6 -0
- data/test/models/treasure.rb +8 -0
- data/test/models/vertex.rb +9 -0
- data/test/models/warehouse_thing.rb +5 -0
- data/test/schema/mysql_specific_schema.rb +24 -0
- data/test/schema/postgresql_specific_schema.rb +114 -0
- data/test/schema/schema.rb +493 -0
- data/test/schema/schema2.rb +6 -0
- data/test/schema/sqlite_specific_schema.rb +25 -0
- metadata +237 -7
@@ -0,0 +1,493 @@
|
|
1
|
+
|
2
|
+
ActiveRecord::Schema.define do
|
3
|
+
def except(adapter_names_to_exclude)
|
4
|
+
unless [adapter_names_to_exclude].flatten.include?(adapter_name)
|
5
|
+
yield
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
#put adapter specific setup here
|
10
|
+
case adapter_name
|
11
|
+
# For Firebird, set the sequence values 10000 when create_table is called;
|
12
|
+
# this prevents primary key collisions between "normally" created records
|
13
|
+
# and fixture-based (YAML) records.
|
14
|
+
when "Firebird"
|
15
|
+
def create_table(*args, &block)
|
16
|
+
ActiveRecord::Base.connection.create_table(*args, &block)
|
17
|
+
ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# Please keep these create table statements in alphabetical order
|
23
|
+
# unless the ordering matters. In which case, define them below
|
24
|
+
create_table :accounts, :force => true do |t|
|
25
|
+
t.integer :firm_id
|
26
|
+
t.string :firm_name
|
27
|
+
t.integer :credit_limit
|
28
|
+
end
|
29
|
+
|
30
|
+
create_table :audit_logs, :force => true do |t|
|
31
|
+
t.column :message, :string, :null=>false
|
32
|
+
t.column :developer_id, :integer, :null=>false
|
33
|
+
end
|
34
|
+
|
35
|
+
create_table :authors, :force => true do |t|
|
36
|
+
t.string :name, :null => false
|
37
|
+
t.integer :author_address_id
|
38
|
+
t.integer :author_address_extra_id
|
39
|
+
end
|
40
|
+
|
41
|
+
create_table :author_addresses, :force => true do |t|
|
42
|
+
end
|
43
|
+
|
44
|
+
create_table :author_favorites, :force => true do |t|
|
45
|
+
t.column :author_id, :integer
|
46
|
+
t.column :favorite_author_id, :integer
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
create_table :auto_id_tests, :force => true, :id => false do |t|
|
51
|
+
t.primary_key :auto_id
|
52
|
+
t.integer :value
|
53
|
+
end
|
54
|
+
|
55
|
+
create_table :binaries, :force => true do |t|
|
56
|
+
t.binary :data
|
57
|
+
end
|
58
|
+
|
59
|
+
create_table :birds, :force => true do |t|
|
60
|
+
t.string :name
|
61
|
+
t.integer :pirate_id
|
62
|
+
end
|
63
|
+
|
64
|
+
create_table :books, :force => true do |t|
|
65
|
+
t.column :name, :string
|
66
|
+
end
|
67
|
+
|
68
|
+
create_table :booleantests, :force => true do |t|
|
69
|
+
t.boolean :value
|
70
|
+
end
|
71
|
+
|
72
|
+
create_table "CamelCase", :force => true do |t|
|
73
|
+
t.string :name
|
74
|
+
end
|
75
|
+
|
76
|
+
create_table :categories, :force => true do |t|
|
77
|
+
t.string :name, :null => false
|
78
|
+
t.string :type
|
79
|
+
t.integer :categorizations_count
|
80
|
+
end
|
81
|
+
|
82
|
+
create_table :categories_posts, :force => true, :id => false do |t|
|
83
|
+
t.integer :category_id, :null => false
|
84
|
+
t.integer :post_id, :null => false
|
85
|
+
end
|
86
|
+
|
87
|
+
create_table :categorizations, :force => true do |t|
|
88
|
+
t.column :category_id, :integer
|
89
|
+
t.column :post_id, :integer
|
90
|
+
t.column :author_id, :integer
|
91
|
+
end
|
92
|
+
|
93
|
+
create_table :citations, :force => true do |t|
|
94
|
+
t.column :book1_id, :integer
|
95
|
+
t.column :book2_id, :integer
|
96
|
+
end
|
97
|
+
|
98
|
+
create_table :clubs, :force => true do |t|
|
99
|
+
t.string :name
|
100
|
+
end
|
101
|
+
|
102
|
+
create_table :colnametests, :force => true do |t|
|
103
|
+
t.integer :references, :null => false
|
104
|
+
end
|
105
|
+
|
106
|
+
create_table :comments, :force => true do |t|
|
107
|
+
t.integer :post_id, :null => false
|
108
|
+
t.text :body, :null => false
|
109
|
+
t.string :type
|
110
|
+
end
|
111
|
+
|
112
|
+
create_table :companies, :force => true do |t|
|
113
|
+
t.string :type
|
114
|
+
t.string :ruby_type
|
115
|
+
t.integer :firm_id
|
116
|
+
t.string :firm_name
|
117
|
+
t.string :name
|
118
|
+
t.integer :client_of
|
119
|
+
t.integer :rating, :default => 1
|
120
|
+
end
|
121
|
+
|
122
|
+
add_index :companies, [:firm_id, :type, :rating, :ruby_type], :name => "company_index"
|
123
|
+
|
124
|
+
create_table :computers, :force => true do |t|
|
125
|
+
t.integer :developer, :null => false
|
126
|
+
t.integer :extendedWarranty, :null => false
|
127
|
+
end
|
128
|
+
|
129
|
+
create_table :contracts, :force => true do |t|
|
130
|
+
t.integer :developer_id
|
131
|
+
t.integer :company_id
|
132
|
+
end
|
133
|
+
|
134
|
+
create_table :customers, :force => true do |t|
|
135
|
+
t.string :name
|
136
|
+
t.integer :balance, :default => 0
|
137
|
+
t.string :address_street
|
138
|
+
t.string :address_city
|
139
|
+
t.string :address_country
|
140
|
+
t.string :gps_location
|
141
|
+
end
|
142
|
+
|
143
|
+
create_table :developers, :force => true do |t|
|
144
|
+
t.string :name
|
145
|
+
t.integer :salary, :default => 70000
|
146
|
+
t.datetime :created_at
|
147
|
+
t.datetime :updated_at
|
148
|
+
end
|
149
|
+
|
150
|
+
create_table :developers_projects, :force => true, :id => false do |t|
|
151
|
+
t.integer :developer_id, :null => false
|
152
|
+
t.integer :project_id, :null => false
|
153
|
+
t.date :joined_on
|
154
|
+
t.integer :access_level, :default => 1
|
155
|
+
end
|
156
|
+
|
157
|
+
create_table :edges, :force => true do |t|
|
158
|
+
t.column :source_id, :integer, :null => false
|
159
|
+
t.column :sink_id, :integer, :null => false
|
160
|
+
end
|
161
|
+
add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index'
|
162
|
+
|
163
|
+
|
164
|
+
create_table :entrants, :force => true do |t|
|
165
|
+
t.string :name, :null => false
|
166
|
+
t.integer :course_id, :null => false
|
167
|
+
end
|
168
|
+
|
169
|
+
create_table :essays, :force => true do |t|
|
170
|
+
t.string :name
|
171
|
+
t.string :writer_id
|
172
|
+
t.string :writer_type
|
173
|
+
end
|
174
|
+
|
175
|
+
create_table :events, :force => true do |t|
|
176
|
+
t.string :title, :limit => 5
|
177
|
+
end
|
178
|
+
|
179
|
+
create_table :funny_jokes, :force => true do |t|
|
180
|
+
t.string :name
|
181
|
+
end
|
182
|
+
|
183
|
+
create_table :goofy_string_id, :force => true, :id => false do |t|
|
184
|
+
t.string :id, :null => false
|
185
|
+
t.string :info
|
186
|
+
end
|
187
|
+
|
188
|
+
create_table :items, :force => true do |t|
|
189
|
+
t.column :name, :integer
|
190
|
+
end
|
191
|
+
|
192
|
+
create_table :inept_wizards, :force => true do |t|
|
193
|
+
t.column :name, :string, :null => false
|
194
|
+
t.column :city, :string, :null => false
|
195
|
+
t.column :type, :string
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
create_table :jobs, :force => true do |t|
|
200
|
+
t.integer :ideal_reference_id
|
201
|
+
end
|
202
|
+
|
203
|
+
create_table :keyboards, :force => true, :id => false do |t|
|
204
|
+
t.primary_key :key_number
|
205
|
+
t.string :name
|
206
|
+
end
|
207
|
+
|
208
|
+
create_table :legacy_things, :force => true do |t|
|
209
|
+
t.integer :tps_report_number
|
210
|
+
t.integer :version, :null => false, :default => 0
|
211
|
+
end
|
212
|
+
|
213
|
+
create_table :lock_without_defaults, :force => true do |t|
|
214
|
+
t.column :lock_version, :integer
|
215
|
+
end
|
216
|
+
|
217
|
+
create_table :lock_without_defaults_cust, :force => true do |t|
|
218
|
+
t.column :custom_lock_version, :integer
|
219
|
+
end
|
220
|
+
|
221
|
+
create_table :mateys, :id => false, :force => true do |t|
|
222
|
+
t.column :pirate_id, :integer
|
223
|
+
t.column :target_id, :integer
|
224
|
+
t.column :weight, :integer
|
225
|
+
end
|
226
|
+
|
227
|
+
create_table :members, :force => true do |t|
|
228
|
+
t.string :name
|
229
|
+
t.integer :member_type_id
|
230
|
+
end
|
231
|
+
|
232
|
+
create_table :member_details, :force => true do |t|
|
233
|
+
t.integer :member_id
|
234
|
+
t.integer :organization_id
|
235
|
+
t.string :extra_data
|
236
|
+
end
|
237
|
+
|
238
|
+
create_table :memberships, :force => true do |t|
|
239
|
+
t.datetime :joined_on
|
240
|
+
t.integer :club_id, :member_id
|
241
|
+
t.boolean :favourite, :default => false
|
242
|
+
t.string :type
|
243
|
+
end
|
244
|
+
|
245
|
+
create_table :member_types, :force => true do |t|
|
246
|
+
t.string :name
|
247
|
+
end
|
248
|
+
|
249
|
+
create_table :references, :force => true do |t|
|
250
|
+
t.integer :person_id
|
251
|
+
t.integer :job_id
|
252
|
+
t.boolean :favourite
|
253
|
+
t.integer :lock_version, :default => 0
|
254
|
+
end
|
255
|
+
|
256
|
+
create_table :minimalistics, :force => true do |t|
|
257
|
+
end
|
258
|
+
|
259
|
+
create_table :mixed_case_monkeys, :force => true, :id => false do |t|
|
260
|
+
t.primary_key :monkeyID
|
261
|
+
t.integer :fleaCount
|
262
|
+
end
|
263
|
+
|
264
|
+
create_table :mixins, :force => true do |t|
|
265
|
+
t.integer :parent_id
|
266
|
+
t.integer :pos
|
267
|
+
t.datetime :created_at
|
268
|
+
t.datetime :updated_at
|
269
|
+
t.integer :lft
|
270
|
+
t.integer :rgt
|
271
|
+
t.integer :root_id
|
272
|
+
t.string :type
|
273
|
+
end
|
274
|
+
|
275
|
+
create_table :movies, :force => true, :id => false do |t|
|
276
|
+
t.primary_key :movieid
|
277
|
+
t.string :name
|
278
|
+
end
|
279
|
+
|
280
|
+
create_table :numeric_data, :force => true do |t|
|
281
|
+
t.decimal :bank_balance, :precision => 10, :scale => 2
|
282
|
+
t.decimal :big_bank_balance, :precision => 15, :scale => 2
|
283
|
+
t.decimal :world_population, :precision => 10, :scale => 0
|
284
|
+
t.decimal :my_house_population, :precision => 2, :scale => 0
|
285
|
+
t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78
|
286
|
+
t.float :temperature
|
287
|
+
end
|
288
|
+
|
289
|
+
create_table :orders, :force => true do |t|
|
290
|
+
t.string :name
|
291
|
+
t.integer :billing_customer_id
|
292
|
+
t.integer :shipping_customer_id
|
293
|
+
end
|
294
|
+
|
295
|
+
create_table :organizations, :force => true do |t|
|
296
|
+
t.string :name
|
297
|
+
end
|
298
|
+
|
299
|
+
create_table :owners, :primary_key => :owner_id ,:force => true do |t|
|
300
|
+
t.string :name
|
301
|
+
t.column :updated_at, :datetime
|
302
|
+
t.column :happy_at, :datetime
|
303
|
+
end
|
304
|
+
|
305
|
+
|
306
|
+
create_table :paint_colors, :force => true do |t|
|
307
|
+
t.integer :non_poly_one_id
|
308
|
+
end
|
309
|
+
|
310
|
+
create_table :paint_textures, :force => true do |t|
|
311
|
+
t.integer :non_poly_two_id
|
312
|
+
end
|
313
|
+
|
314
|
+
create_table :parrots, :force => true do |t|
|
315
|
+
t.column :name, :string
|
316
|
+
t.column :parrot_sti_class, :string
|
317
|
+
t.column :killer_id, :integer
|
318
|
+
t.column :created_at, :datetime
|
319
|
+
t.column :created_on, :datetime
|
320
|
+
t.column :updated_at, :datetime
|
321
|
+
t.column :updated_on, :datetime
|
322
|
+
end
|
323
|
+
|
324
|
+
create_table :parrots_pirates, :id => false, :force => true do |t|
|
325
|
+
t.column :parrot_id, :integer
|
326
|
+
t.column :pirate_id, :integer
|
327
|
+
end
|
328
|
+
|
329
|
+
create_table :parrots_treasures, :id => false, :force => true do |t|
|
330
|
+
t.column :parrot_id, :integer
|
331
|
+
t.column :treasure_id, :integer
|
332
|
+
end
|
333
|
+
|
334
|
+
create_table :people, :force => true do |t|
|
335
|
+
t.string :first_name, :null => false
|
336
|
+
t.references :primary_contact
|
337
|
+
t.string :gender, :limit => 1
|
338
|
+
t.integer :lock_version, :null => false, :default => 0
|
339
|
+
end
|
340
|
+
|
341
|
+
create_table :pets, :primary_key => :pet_id ,:force => true do |t|
|
342
|
+
t.string :name
|
343
|
+
t.integer :owner_id, :integer
|
344
|
+
end
|
345
|
+
|
346
|
+
create_table :pirates, :force => true do |t|
|
347
|
+
t.column :catchphrase, :string
|
348
|
+
t.column :parrot_id, :integer
|
349
|
+
t.column :created_on, :datetime
|
350
|
+
t.column :updated_on, :datetime
|
351
|
+
end
|
352
|
+
|
353
|
+
create_table :posts, :force => true do |t|
|
354
|
+
t.integer :author_id
|
355
|
+
t.string :title, :null => false
|
356
|
+
t.text :body, :null => false
|
357
|
+
t.string :type
|
358
|
+
t.integer :comments_count, :default => 0
|
359
|
+
t.integer :taggings_count, :default => 0
|
360
|
+
end
|
361
|
+
|
362
|
+
create_table :price_estimates, :force => true do |t|
|
363
|
+
t.string :estimate_of_type
|
364
|
+
t.integer :estimate_of_id
|
365
|
+
t.integer :price
|
366
|
+
end
|
367
|
+
|
368
|
+
create_table :projects, :force => true do |t|
|
369
|
+
t.string :name
|
370
|
+
t.string :type
|
371
|
+
end
|
372
|
+
|
373
|
+
create_table :readers, :force => true do |t|
|
374
|
+
t.integer :post_id, :null => false
|
375
|
+
t.integer :person_id, :null => false
|
376
|
+
end
|
377
|
+
|
378
|
+
create_table :shape_expressions, :force => true do |t|
|
379
|
+
t.string :paint_type
|
380
|
+
t.integer :paint_id
|
381
|
+
t.string :shape_type
|
382
|
+
t.integer :shape_id
|
383
|
+
end
|
384
|
+
|
385
|
+
create_table :ships, :force => true do |t|
|
386
|
+
t.string :name
|
387
|
+
t.integer :pirate_id
|
388
|
+
t.datetime :created_at
|
389
|
+
t.datetime :created_on
|
390
|
+
t.datetime :updated_at
|
391
|
+
t.datetime :updated_on
|
392
|
+
end
|
393
|
+
|
394
|
+
create_table :ship_parts, :force => true do |t|
|
395
|
+
t.string :name
|
396
|
+
t.integer :ship_id
|
397
|
+
end
|
398
|
+
|
399
|
+
create_table :sponsors, :force => true do |t|
|
400
|
+
t.integer :club_id
|
401
|
+
t.integer :sponsorable_id
|
402
|
+
t.string :sponsorable_type
|
403
|
+
end
|
404
|
+
|
405
|
+
create_table :subscribers, :force => true, :id => false do |t|
|
406
|
+
t.string :nick, :null => false
|
407
|
+
t.string :name
|
408
|
+
end
|
409
|
+
add_index :subscribers, :nick, :unique => true
|
410
|
+
|
411
|
+
create_table :subscriptions, :force => true do |t|
|
412
|
+
t.string :subscriber_id
|
413
|
+
t.integer :book_id
|
414
|
+
end
|
415
|
+
|
416
|
+
create_table :tasks, :force => true do |t|
|
417
|
+
t.datetime :starting
|
418
|
+
t.datetime :ending
|
419
|
+
end
|
420
|
+
|
421
|
+
create_table :topics, :force => true do |t|
|
422
|
+
t.string :title
|
423
|
+
t.string :author_name
|
424
|
+
t.string :author_email_address
|
425
|
+
t.datetime :written_on
|
426
|
+
t.time :bonus_time
|
427
|
+
t.date :last_read
|
428
|
+
t.text :content
|
429
|
+
t.boolean :approved, :default => true
|
430
|
+
t.integer :replies_count, :default => 0
|
431
|
+
t.integer :parent_id
|
432
|
+
t.string :parent_title
|
433
|
+
t.string :type
|
434
|
+
end
|
435
|
+
|
436
|
+
create_table :taggings, :force => true do |t|
|
437
|
+
t.column :tag_id, :integer
|
438
|
+
t.column :super_tag_id, :integer
|
439
|
+
t.column :taggable_type, :string
|
440
|
+
t.column :taggable_id, :integer
|
441
|
+
end
|
442
|
+
|
443
|
+
create_table :tags, :force => true do |t|
|
444
|
+
t.column :name, :string
|
445
|
+
t.column :taggings_count, :integer, :default => 0
|
446
|
+
end
|
447
|
+
|
448
|
+
create_table :toys, :primary_key => :toy_id ,:force => true do |t|
|
449
|
+
t.string :name
|
450
|
+
t.integer :pet_id, :integer
|
451
|
+
end
|
452
|
+
|
453
|
+
create_table :treasures, :force => true do |t|
|
454
|
+
t.column :name, :string
|
455
|
+
t.column :looter_id, :integer
|
456
|
+
t.column :looter_type, :string
|
457
|
+
end
|
458
|
+
|
459
|
+
create_table :vertices, :force => true do |t|
|
460
|
+
t.column :label, :string
|
461
|
+
end
|
462
|
+
|
463
|
+
create_table 'warehouse-things', :force => true do |t|
|
464
|
+
t.integer :value
|
465
|
+
end
|
466
|
+
|
467
|
+
[:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
|
468
|
+
create_table(t, :force => true) { }
|
469
|
+
end
|
470
|
+
|
471
|
+
create_table :guids, :force => true do |t|
|
472
|
+
t.column :key, :string
|
473
|
+
end
|
474
|
+
|
475
|
+
create_table :integer_limits, :force => true do |t|
|
476
|
+
t.integer :"c_int_without_limit"
|
477
|
+
(1..8).each do |i|
|
478
|
+
t.integer :"c_int_#{i}", :limit => i
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
except 'SQLite' do
|
483
|
+
# fk_test_has_fk should be before fk_test_has_pk
|
484
|
+
create_table :fk_test_has_fk, :force => true do |t|
|
485
|
+
t.integer :fk_id, :null => false
|
486
|
+
end
|
487
|
+
|
488
|
+
create_table :fk_test_has_pk, :force => true do |t|
|
489
|
+
end
|
490
|
+
|
491
|
+
execute "ALTER TABLE fk_test_has_fk ADD CONSTRAINT fk_name FOREIGN KEY (#{quote_column_name 'fk_id'}) REFERENCES #{quote_table_name 'fk_test_has_pk'} (#{quote_column_name 'id'})"
|
492
|
+
end
|
493
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
ActiveRecord::Schema.define do
|
2
|
+
# For sqlite 3.1.0+, make a table with a autoincrement column
|
3
|
+
if supports_autoincrement?
|
4
|
+
create_table :table_with_autoincrement, :force => true do |t|
|
5
|
+
t.column :name, :string
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
execute "DROP TABLE fk_test_has_fk" rescue nil
|
10
|
+
execute "DROP TABLE fk_test_has_pk" rescue nil
|
11
|
+
execute <<_SQL
|
12
|
+
CREATE TABLE 'fk_test_has_pk' (
|
13
|
+
'id' INTEGER NOT NULL PRIMARY KEY
|
14
|
+
);
|
15
|
+
_SQL
|
16
|
+
|
17
|
+
execute <<_SQL
|
18
|
+
CREATE TABLE 'fk_test_has_fk' (
|
19
|
+
'id' INTEGER NOT NULL PRIMARY KEY,
|
20
|
+
'fk_id' INTEGER NOT NULL,
|
21
|
+
|
22
|
+
FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id')
|
23
|
+
);
|
24
|
+
_SQL
|
25
|
+
end
|