schema.rb 22.6 KB
Newer Older
1 2
# encoding: utf-8

3 4 5 6
ActiveRecord::Schema.define do
  def except(adapter_names_to_exclude)
    unless [adapter_names_to_exclude].flatten.include?(adapter_name)
      yield
7
    end
8
  end
J
Jeremy Kemper 已提交
9

10 11
  #put adapter specific setup here
  case adapter_name
12 13 14 15 16 17 18 19 20
  when "PostgreSQL"
    enable_uuid_ossp!(ActiveRecord::Base.connection)
    create_table :uuid_parents, id: :uuid, force: true do |t|
      t.string :name
    end
    create_table :uuid_children, id: :uuid, force: true do |t|
      t.string :name
      t.uuid :uuid_parent_id
    end
21
  end
J
Jeremy Kemper 已提交
22

23

24 25 26 27 28 29 30
  # ------------------------------------------------------------------- #
  #                                                                     #
  #   Please keep these create table statements in alphabetical order   #
  #   unless the ordering matters.  In which case, define them below.   #
  #                                                                     #
  # ------------------------------------------------------------------- #

31
  create_table :accounts, force: true do |t|
32
    t.integer :firm_id
33
    t.string  :firm_name
34 35
    t.integer :credit_limit
  end
36

37
  create_table :admin_accounts, force: true do |t|
38 39 40
    t.string :name
  end

41
  create_table :admin_users, force: true do |t|
42
    t.string :name
43
    t.string :settings, null: true, limit: 1024
44 45
    # MySQL does not allow default values for blobs. Fake it out with a
    # big varchar below.
46 47 48
    t.string :preferences, null: true, default: '', limit: 1024
    t.string :json_data, null: true, limit: 1024
    t.string :json_data_empty, null: true, default: "", limit: 1024
49
    t.text :params
50 51 52
    t.references :account
  end

53
  create_table :aircraft, force: true do |t|
54 55 56
    t.string :name
  end

57 58 59 60 61 62 63 64
  create_table :articles, force: true do |t|
  end

  create_table :articles_magazines, force: true do |t|
    t.references :article
    t.references :magazine
  end

65 66 67 68 69
  create_table :articles_tags, force: true do |t|
    t.references :article
    t.references :tag
  end

70 71 72
  create_table :audit_logs, force: true do |t|
    t.column :message, :string, null: false
    t.column :developer_id, :integer, null: false
73
    t.integer :unvalidated_developer_id
74
  end
75

76 77
  create_table :authors, force: true do |t|
    t.string :name, null: false
78 79
    t.integer :author_address_id
    t.integer :author_address_extra_id
80 81
    t.string :organization_id
    t.string :owned_essay_id
82
  end
83

84
  create_table :author_addresses, force: true do |t|
85
  end
J
Jeremy Kemper 已提交
86

87
  create_table :author_favorites, force: true do |t|
88 89 90
    t.column :author_id, :integer
    t.column :favorite_author_id, :integer
  end
J
Jeremy Kemper 已提交
91

92
  create_table :auto_id_tests, force: true, id: false do |t|
93 94 95
    t.primary_key :auto_id
    t.integer     :value
  end
J
Jeremy Kemper 已提交
96

97
  create_table :binaries, force: true do |t|
98
    t.string :name
99
    t.binary :data
100
    t.binary :short_data, limit: 2048
101
  end
J
Jeremy Kemper 已提交
102

103
  create_table :birds, force: true do |t|
104
    t.string :name
105
    t.string :color
106 107 108
    t.integer :pirate_id
  end

109
  create_table :books, force: true do |t|
110
    t.integer :author_id
111
    t.string :format
112
    t.column :name, :string
113
    t.column :status, :integer, default: 0
Y
Yury Korolev 已提交
114
    t.column :read_status, :integer, default: 0
115
    t.column :nullable_status, :integer
116
  end
J
Jeremy Kemper 已提交
117

118
  create_table :booleans, force: true do |t|
119
    t.boolean :value
120
    t.boolean :has_fun, null: false, default: false
121
  end
J
Jeremy Kemper 已提交
122

123
  create_table :bulbs, force: true do |t|
124 125
    t.integer :car_id
    t.string  :name
126
    t.boolean :frickinawesome
127
    t.string :color
128 129
  end

130
  create_table "CamelCase", force: true do |t|
131 132 133
    t.string :name
  end

134
  create_table :cars, force: true do |t|
135 136 137
    t.string  :name
    t.integer :engines_count
    t.integer :wheels_count
138
    t.column :lock_version, :integer, null: false, default: 0
139
    t.timestamps
140 141
  end

142 143
  create_table :categories, force: true do |t|
    t.string :name, null: false
144
    t.string :type
145
    t.integer :categorizations_count
146
  end
J
Jeremy Kemper 已提交
147

148 149 150
  create_table :categories_posts, force: true, id: false do |t|
    t.integer :category_id, null: false
    t.integer :post_id, null: false
151
  end
152

153
  create_table :categorizations, force: true do |t|
154
    t.column :category_id, :integer
155
    t.string :named_category_name
156 157
    t.column :post_id, :integer
    t.column :author_id, :integer
158
    t.column :special, :boolean
159
  end
J
Jeremy Kemper 已提交
160

161
  create_table :citations, force: true do |t|
162 163 164
    t.column :book1_id, :integer
    t.column :book2_id, :integer
  end
165

166
  create_table :clubs, force: true do |t|
167
    t.string :name
168
    t.integer :category_id
169
  end
J
Jeremy Kemper 已提交
170

171
  create_table :collections, force: true do |t|
172 173 174
    t.string :name
  end

175 176
  create_table :colnametests, force: true do |t|
    t.integer :references, null: false
177
  end
J
Jeremy Kemper 已提交
178

179 180 181 182
  create_table :columns, force: true do |t|
    t.references :record
  end

183 184
  create_table :comments, force: true do |t|
    t.integer :post_id, null: false
185 186 187
    # use VARCHAR2(4000) instead of CLOB datatype as CLOB data type has many limitations in
    # Oracle SELECT WHERE clause which causes many unit test failures
    if current_adapter?(:OracleAdapter)
188
      t.string  :body, null: false, limit: 4000
189
    else
190
      t.text    :body, null: false
191
    end
192
    t.string  :type
193
    t.integer :tags_count, default: 0
194
    t.integer :children_count, default: 0
195
    t.integer :parent_id
196 197 198
    t.references :author, polymorphic: true
    t.string :resource_id
    t.string :resource_type
199
  end
200

201
  create_table :companies, force: true do |t|
202 203
    t.string  :type
    t.integer :firm_id
204
    t.string  :firm_name
205 206
    t.string  :name
    t.integer :client_of
207
    t.integer :rating, default: 1
208
    t.integer :account_id
209
    t.string :description, default: ""
210
  end
211

212 213 214
  add_index :companies, [:firm_id, :type, :rating], name: "company_index"
  add_index :companies, [:firm_id, :type], name: "company_partial_index", where: "rating > 10"
  add_index :companies, :name, name: 'company_name_index', using: :btree
215

216
  create_table :vegetables, force: true do |t|
217
    t.string :name
218
    t.integer :seller_id
219 220 221
    t.string :custom_type
  end

222
  create_table :computers, force: true do |t|
223
    t.string :system
224 225
    t.integer :developer, null: false
    t.integer :extendedWarranty, null: false
226
  end
227

228
  create_table :contracts, force: true do |t|
229 230 231
    t.integer :developer_id
    t.integer :company_id
  end
232

233
  create_table :customers, force: true do |t|
234
    t.string  :name
235
    t.integer :balance, default: 0
236 237 238 239 240
    t.string  :address_street
    t.string  :address_city
    t.string  :address_country
    t.string  :gps_location
  end
241

242
  create_table :dashboards, force: true, id: false do |t|
243 244 245
    t.string :dashboard_id
    t.string :name
  end
246

247
  create_table :developers, force: true do |t|
248
    t.string   :name
249
    t.integer  :salary, default: 70000
250 251
    t.datetime :created_at
    t.datetime :updated_at
252 253
    t.datetime :created_on
    t.datetime :updated_on
254
  end
255

256 257 258
  create_table :developers_projects, force: true, id: false do |t|
    t.integer :developer_id, null: false
    t.integer :project_id, null: false
259
    t.date    :joined_on
260
    t.integer :access_level, default: 1
261
  end
262

263 264 265 266
  create_table :dog_lovers, force: true do |t|
    t.integer :trained_dogs_count, default: 0
    t.integer :bred_dogs_count, default: 0
    t.integer :dogs_count, default: 0
267 268
  end

269
  create_table :dogs, force: true do |t|
270 271
    t.integer :trainer_id
    t.integer :breeder_id
272
    t.integer :dog_lover_id
273
    t.string  :alias
274 275
  end

276 277 278
  create_table :edges, force: true, id: false do |t|
    t.column :source_id, :integer, null: false
    t.column :sink_id,   :integer, null: false
279
  end
280
  add_index :edges, [:source_id, :sink_id], unique: true, name: 'unique_edge_index'
281

282
  create_table :engines, force: true do |t|
283 284
    t.integer :car_id
  end
285

286 287 288
  create_table :entrants, force: true do |t|
    t.string  :name, null: false
    t.integer :course_id, null: false
289
  end
290

291
  create_table :essays, force: true do |t|
292 293 294
    t.string :name
    t.string :writer_id
    t.string :writer_type
295 296
    t.string :category_id
    t.string :author_id
297 298
  end

299 300
  create_table :events, force: true do |t|
    t.string :title, limit: 5
301 302
  end

303
  create_table :eyes, force: true do |t|
304 305
  end

306
  create_table :funny_jokes, force: true do |t|
307
    t.string :name
308 309
  end

310
  create_table :cold_jokes, force: true do |t|
311 312 313
    t.string :name
  end

314
  create_table :friendships, force: true do |t|
315
    t.integer :friend_id
316
    t.integer :follower_id
317 318
  end

319 320
  create_table :goofy_string_id, force: true, id: false do |t|
    t.string :id, null: false
321 322 323
    t.string :info
  end

324
  create_table :having, force: true do |t|
325 326 327
    t.string :where
  end

328
  create_table :guids, force: true do |t|
329
    t.column :key, :string
330 331
  end

332 333 334
  create_table :inept_wizards, force: true do |t|
    t.column :name, :string, null: false
    t.column :city, :string, null: false
335
    t.column :type, :string
336 337
  end

338
  create_table :integer_limits, force: true do |t|
339 340
    t.integer :"c_int_without_limit"
    (1..8).each do |i|
341
      t.integer :"c_int_#{i}", limit: i
342 343 344
    end
  end

345
  create_table :invoices, force: true do |t|
346 347 348 349
    t.integer :balance
    t.datetime :updated_at
  end

350
  create_table :iris, force: true do |t|
351 352 353 354
    t.references :eye
    t.string     :color
  end

355
  create_table :items, force: true do |t|
356 357
    t.column :name, :string
  end
358

359
  create_table :jobs, force: true do |t|
360 361 362
    t.integer :ideal_reference_id
  end

P
Pablo Torres 已提交
363
  create_table :keyboards, force: true, id: false do |t|
364 365
    t.primary_key :key_number
    t.string      :name
366 367
  end

368
  create_table :legacy_things, force: true do |t|
369
    t.integer :tps_report_number
370
    t.integer :version, null: false, default: 0
371 372
  end

373
  create_table :lessons, force: true do |t|
374 375 376
    t.string :name
  end

377
  create_table :lessons_students, id: false, force: true do |t|
378 379 380 381
    t.references :lesson
    t.references :student
  end

382
  create_table :lint_models, force: true
383

384
  create_table :line_items, force: true do |t|
385 386 387 388
    t.integer :invoice_id
    t.integer :amount
  end

389
  create_table :lock_without_defaults, force: true do |t|
390 391
    t.column :lock_version, :integer
  end
392

393
  create_table :lock_without_defaults_cust, force: true do |t|
394
    t.column :custom_lock_version, :integer
395
  end
396

397 398 399
  create_table :magazines, force: true do |t|
  end

400
  create_table :mateys, id: false, force: true do |t|
401 402 403
    t.column :pirate_id, :integer
    t.column :target_id, :integer
    t.column :weight, :integer
404
  end
J
Jeremy Kemper 已提交
405

406
  create_table :members, force: true do |t|
407
    t.string :name
408
    t.integer :member_type_id
J
Jeremy Kemper 已提交
409 410
  end

411
  create_table :member_details, force: true do |t|
412 413 414 415 416
    t.integer :member_id
    t.integer :organization_id
    t.string :extra_data
  end

417
  create_table :member_friends, force: true, id: false do |t|
418 419 420 421
    t.integer :member_id
    t.integer :friend_id
  end

422
  create_table :memberships, force: true do |t|
423 424
    t.datetime :joined_on
    t.integer :club_id, :member_id
425
    t.boolean :favourite, default: false
426
    t.string :type
J
Jeremy Kemper 已提交
427
  end
428

429
  create_table :member_types, force: true do |t|
430 431 432
    t.string :name
  end

433
  create_table :minivans, force: true, id: false do |t|
434 435 436
    t.string :minivan_id
    t.string :name
    t.string :speedometer_id
437
    t.string :color
438
  end
439

440
  create_table :minimalistics, force: true do |t|
441
  end
J
Jeremy Kemper 已提交
442

443
  create_table :mixed_case_monkeys, force: true, id: false do |t|
444 445
    t.primary_key :monkeyID
    t.integer     :fleaCount
446
  end
J
Jeremy Kemper 已提交
447

448
  create_table :mixins, force: true do |t|
449 450 451 452 453 454 455 456
    t.integer  :parent_id
    t.integer  :pos
    t.datetime :created_at
    t.datetime :updated_at
    t.integer  :lft
    t.integer  :rgt
    t.integer  :root_id
    t.string   :type
457
  end
458

459
  create_table :movies, force: true, id: false do |t|
460 461
    t.primary_key :movieid
    t.string      :name
462
  end
J
Jeremy Kemper 已提交
463

464 465 466 467 468 469
  create_table :numeric_data, force: true do |t|
    t.decimal :bank_balance, precision: 10, scale: 2
    t.decimal :big_bank_balance, precision: 15, scale: 2
    t.decimal :world_population, precision: 10, scale: 0
    t.decimal :my_house_population, precision: 2, scale: 0
    t.decimal :decimal_number_with_default, precision: 3, scale: 2, default: 2.78
470
    t.float   :temperature
471
    # Oracle/SQLServer supports precision up to 38
472
    if current_adapter?(:OracleAdapter, :SQLServerAdapter)
473
      t.decimal :atoms_in_universe, precision: 38, scale: 0
474
    else
475
      t.decimal :atoms_in_universe, precision: 55, scale: 0
476
    end
477
  end
478

479
  create_table :orders, force: true do |t|
480 481 482
    t.string  :name
    t.integer :billing_customer_id
    t.integer :shipping_customer_id
483
  end
484

485
  create_table :organizations, force: true do |t|
486 487 488
    t.string :name
  end

489
  create_table :owners, primary_key: :owner_id, force: true do |t|
490
    t.string :name
491 492
    t.column :updated_at, :datetime
    t.column :happy_at,   :datetime
493
    t.string :essay_id
494 495
  end

496
  create_table :paint_colors, force: true do |t|
497
    t.integer :non_poly_one_id
498 499
  end

500
  create_table :paint_textures, force: true do |t|
501
    t.integer :non_poly_two_id
502
  end
503

504
  create_table :parrots, force: true do |t|
505
    t.column :name, :string
506
    t.column :color, :string
507 508
    t.column :parrot_sti_class, :string
    t.column :killer_id, :integer
509 510 511 512 513 514
    t.column :created_at, :datetime
    t.column :created_on, :datetime
    t.column :updated_at, :datetime
    t.column :updated_on, :datetime
  end

515
  create_table :parrots_pirates, id: false, force: true do |t|
516 517 518 519
    t.column :parrot_id, :integer
    t.column :pirate_id, :integer
  end

520
  create_table :parrots_treasures, id: false, force: true do |t|
521 522 523
    t.column :parrot_id, :integer
    t.column :treasure_id, :integer
  end
524

525 526
  create_table :people, force: true do |t|
    t.string     :first_name, null: false
527
    t.references :primary_contact
528
    t.string     :gender, limit: 1
529
    t.references :number1_fan
530
    t.integer    :lock_version, null: false, default: 0
531
    t.string     :comments
532 533
    t.integer    :followers_count, default: 0
    t.integer    :friends_too_count, default: 0
534 535
    t.references :best_friend
    t.references :best_friend_of
536
    t.integer    :insures, null: false, default: 0
537
    t.timestamp :born_at
538
    t.timestamps
539
  end
J
Jon Leighton 已提交
540

541
  create_table :peoples_treasures, id: false, force: true do |t|
542 543 544
    t.column :rich_person_id, :integer
    t.column :treasure_id, :integer
  end
545

546
  create_table :pets, primary_key: :pet_id, force: true do |t|
547
    t.string :name
548
    t.integer :owner_id, :integer
549
    t.timestamps
550
  end
551

552
  create_table :pirates, force: true do |t|
553 554
    t.column :catchphrase, :string
    t.column :parrot_id, :integer
555
    t.integer :non_validated_parrot_id
556 557
    t.column :created_on, :datetime
    t.column :updated_on, :datetime
558
  end
559

560
  create_table :posts, force: true do |t|
561
    t.integer :author_id
562
    t.string  :title, null: false
563 564 565
    # use VARCHAR2(4000) instead of CLOB datatype as CLOB data type has many limitations in
    # Oracle SELECT WHERE clause which causes many unit test failures
    if current_adapter?(:OracleAdapter)
566
      t.string  :body, null: false, limit: 4000
567
    else
568
      t.text    :body, null: false
569
    end
570
    t.string  :type
571 572 573 574 575 576
    t.integer :comments_count, default: 0
    t.integer :taggings_with_delete_all_count, default: 0
    t.integer :taggings_with_destroy_count, default: 0
    t.integer :tags_count, default: 0
    t.integer :tags_with_destroy_count, default: 0
    t.integer :tags_with_nullify_count, default: 0
577
  end
578

579
  create_table :price_estimates, force: true do |t|
580 581 582 583
    t.string :estimate_of_type
    t.integer :estimate_of_id
    t.integer :price
  end
584

585
  create_table :products, force: true do |t|
586
    t.references :collection
587
    t.references :type
588 589 590
    t.string     :name
  end

591 592 593 594
  create_table :product_types, force: true do |t|
    t.string :name
  end

595
  create_table :projects, force: true do |t|
596 597 598 599
    t.string :name
    t.string :type
  end

600
  create_table :randomly_named_table, force: true do |t|
601 602 603 604
    t.string  :some_attribute
    t.integer :another_attribute
  end

605
  create_table :ratings, force: true do |t|
606 607 608 609
    t.integer :comment_id
    t.integer :value
  end

610 611 612 613
  create_table :readers, force: true do |t|
    t.integer :post_id, null: false
    t.integer :person_id, null: false
    t.boolean :skimmer, default: false
614
    t.integer :first_post_id
615 616
  end

617
  create_table :references, force: true do |t|
618 619 620
    t.integer :person_id
    t.integer :job_id
    t.boolean :favourite
621
    t.integer :lock_version, default: 0
622 623
  end

624
  create_table :shape_expressions, force: true do |t|
625 626 627 628 629
    t.string  :paint_type
    t.integer :paint_id
    t.string  :shape_type
    t.integer :shape_id
  end
630

631
  create_table :ships, force: true do |t|
632
    t.string :name
633
    t.integer :pirate_id
634
    t.integer :update_only_pirate_id
635 636 637 638
    t.datetime :created_at
    t.datetime :created_on
    t.datetime :updated_at
    t.datetime :updated_on
639
  end
640

641
  create_table :ship_parts, force: true do |t|
642 643 644
    t.string :name
    t.integer :ship_id
  end
645

646
  create_table :speedometers, force: true, id: false do |t|
647 648 649 650
    t.string :speedometer_id
    t.string :name
    t.string :dashboard_id
  end
651

652
  create_table :sponsors, force: true do |t|
653 654
    t.integer :club_id
    t.integer :sponsorable_id
655
    t.string :sponsorable_type
656
  end
657

658
  create_table :string_key_objects, id: false, primary_key: :id, force: true do |t|
659 660
    t.string     :id
    t.string     :name
661
    t.integer    :lock_version, null: false, default: 0
662 663
  end

664
  create_table :students, force: true do |t|
665
    t.string :name
666 667
    t.boolean :active
    t.integer :college_id
668 669
  end

670 671
  create_table :subscribers, force: true, id: false do |t|
    t.string :nick, null: false
672
    t.string :name
673
    t.column :books_count, :integer, null: false, default: 0
674
  end
675
  add_index :subscribers, :nick, unique: true
676

677
  create_table :subscriptions, force: true do |t|
678 679 680 681
    t.string :subscriber_id
    t.integer :book_id
  end

682
  create_table :tags, force: true do |t|
683
    t.column :name, :string
684
    t.column :taggings_count, :integer, default: 0
685 686
  end

687
  create_table :taggings, force: true do |t|
688 689 690 691
    t.column :tag_id, :integer
    t.column :super_tag_id, :integer
    t.column :taggable_type, :string
    t.column :taggable_id, :integer
692
    t.string :comment
693 694
  end

695
  create_table :tasks, force: true do |t|
696 697
    t.datetime :starting
    t.datetime :ending
698 699
  end

700
  create_table :topics, force: true do |t|
701
    t.string   :title, limit: 250
702 703
    t.string   :author_name
    t.string   :author_email_address
A
Arthur Neves 已提交
704 705 706 707 708
    if mysql_56?
      t.datetime :written_on, limit: 6
    else
      t.datetime :written_on
    end
709 710
    t.time     :bonus_time
    t.date     :last_read
711 712 713
    # use VARCHAR2(4000) instead of CLOB datatype as CLOB data type has many limitations in
    # Oracle SELECT WHERE clause which causes many unit test failures
    if current_adapter?(:OracleAdapter)
714 715
      t.string   :content, limit: 4000
      t.string   :important, limit: 4000
716 717
    else
      t.text     :content
A
Alvaro Bautista 已提交
718
      t.text     :important
719
    end
720 721 722
    t.boolean  :approved, default: true
    t.integer  :replies_count, default: 0
    t.integer  :unique_replies_count, default: 0
723
    t.integer  :parent_id
724
    t.string   :parent_title
725
    t.string   :type
726
    t.string   :group
P
Pratik Naik 已提交
727
    t.timestamps
728 729
  end

730
  create_table :toys, primary_key: :toy_id, force: true do |t|
731 732
    t.string :name
    t.integer :pet_id, :integer
733
    t.timestamps
734 735
  end

736
  create_table :traffic_lights, force: true do |t|
737 738
    t.string   :location
    t.string   :state
739
    t.text     :long_state, null: false
740 741 742 743
    t.datetime :created_at
    t.datetime :updated_at
  end

744
  create_table :treasures, force: true do |t|
745
    t.column :name, :string
746
    t.column :type, :string
747 748 749 750
    t.column :looter_id, :integer
    t.column :looter_type, :string
  end

751
  create_table :tyres, force: true do |t|
752 753 754
    t.integer :car_id
  end

755
  create_table :variants, force: true do |t|
756 757 758 759
    t.references :product
    t.string     :name
  end

760
  create_table :vertices, force: true do |t|
761 762 763
    t.column :label, :string
  end

764
  create_table 'warehouse-things', force: true do |t|
765 766 767 768
    t.integer :value
  end

  [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
769
    create_table(t, force: true) { }
770 771
  end

772
  # NOTE - the following 4 tables are used by models that have :inverse_of options on the associations
773
  create_table :men, force: true do |t|
774 775 776
    t.string  :name
  end

777
  create_table :faces, force: true do |t|
778 779
    t.string  :description
    t.integer :man_id
780
    t.integer :polymorphic_man_id
781
    t.string  :polymorphic_man_type
782 783
    t.integer :polymorphic_man_without_inverse_id
    t.string  :polymorphic_man_without_inverse_type
784 785
    t.integer :horrible_polymorphic_man_id
    t.string  :horrible_polymorphic_man_type
786 787
  end

788
  create_table :interests, force: true do |t|
789 790
    t.string :topic
    t.integer :man_id
791 792
    t.integer :polymorphic_man_id
    t.string :polymorphic_man_type
793 794 795
    t.integer :zine_id
  end

796 797
  create_table :wheels, force: true do |t|
    t.references :wheelable, polymorphic: true
798 799
  end

800
  create_table :zines, force: true do |t|
801 802 803
    t.string :title
  end

804
  create_table :countries, force: true, id: false, primary_key: 'country_id' do |t|
805 806 807
    t.string :country_id
    t.string :name
  end
808
  create_table :treaties, force: true, id: false, primary_key: 'treaty_id' do |t|
809 810 811
    t.string :treaty_id
    t.string :name
  end
812 813 814
  create_table :countries_treaties, force: true, id: false do |t|
    t.string :country_id, null: false
    t.string :treaty_id, null: false
815 816
  end

817
  create_table :liquid, force: true do |t|
818 819
    t.string :name
  end
820
  create_table :molecules, force: true do |t|
821 822 823
    t.integer :liquid_id
    t.string :name
  end
824
  create_table :electrons, force: true do |t|
825 826 827
    t.integer :molecule_id
    t.string :name
  end
828
  create_table :weirds, force: true do |t|
829
    t.string 'a$b'
A
Aaron Patterson 已提交
830
    t.string 'なまえ'
831
    t.string 'from'
832
  end
833

834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
  create_table :hotels, force: true do |t|
  end
  create_table :departments, force: true do |t|
    t.integer :hotel_id
  end
  create_table :cake_designers, force: true do |t|
  end
  create_table :drink_designers, force: true do |t|
  end
  create_table :chefs, force: true do |t|
    t.integer :employable_id
    t.string :employable_type
    t.integer :department_id
  end

849 850
  create_table :records, force: true do |t|
  end
851

852 853
  except 'SQLite' do
    # fk_test_has_fk should be before fk_test_has_pk
854 855
    create_table :fk_test_has_fk, force: true do |t|
      t.integer :fk_id, null: false
856 857
    end

858
    create_table :fk_test_has_pk, force: true do |t|
859 860 861
    end

    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'})"
862 863

    execute "ALTER TABLE lessons_students ADD CONSTRAINT student_id_fk FOREIGN KEY (#{quote_column_name 'student_id'}) REFERENCES #{quote_table_name 'students'} (#{quote_column_name 'id'})"
864
  end
865 866 867 868 869

  create_table :overloaded_types, force: true do |t|
    t.float :overloaded_float, default: 500
    t.float :unoverloaded_float
    t.string :overloaded_string_with_limit, limit: 255
870
    t.string :string_with_default, default: 'the original default'
871
  end
872
end
873

874 875
Course.connection.create_table :courses, force: true do |t|
  t.column :name, :string, null: false
R
Rick Martinez 已提交
876 877 878
  t.column :college_id, :integer
end

879 880
College.connection.create_table :colleges, force: true do |t|
  t.column :name, :string, null: false
881
end