schema.rb 21.5 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 12 13 14 15 16 17 18
  #put adapter specific setup here
  case adapter_name
    # For Firebird, set the sequence values 10000 when create_table is called;
    # this prevents primary key collisions between "normally" created records
    # and fixture-based (YAML) records.
  when "Firebird"
    def create_table(*args, &block)
      ActiveRecord::Base.connection.create_table(*args, &block)
      ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
19
    end
20
  end
J
Jeremy Kemper 已提交
21

22

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

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

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

40
  create_table :admin_users, force: true do |t|
41
    t.string :name
42
    t.string :settings, null: true, limit: 1024
43 44
    # MySQL does not allow default values for blobs. Fake it out with a
    # big varchar below.
45 46 47
    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
48 49 50
    t.references :account
  end

51
  create_table :aircraft, force: true do |t|
52 53 54
    t.string :name
  end

55 56 57
  create_table :audit_logs, force: true do |t|
    t.column :message, :string, null: false
    t.column :developer_id, :integer, null: false
58
    t.integer :unvalidated_developer_id
59
  end
60

61 62
  create_table :authors, force: true do |t|
    t.string :name, null: false
63 64
    t.integer :author_address_id
    t.integer :author_address_extra_id
65 66
    t.string :organization_id
    t.string :owned_essay_id
67
  end
68

69
  create_table :author_addresses, force: true do |t|
70
  end
J
Jeremy Kemper 已提交
71

72
  create_table :author_favorites, force: true do |t|
73 74 75
    t.column :author_id, :integer
    t.column :favorite_author_id, :integer
  end
J
Jeremy Kemper 已提交
76

77
  create_table :auto_id_tests, force: true, id: false do |t|
78 79 80
    t.primary_key :auto_id
    t.integer     :value
  end
J
Jeremy Kemper 已提交
81

82
  create_table :binaries, force: true do |t|
83
    t.string :name
84
    t.binary :data
85
    t.binary :short_data, limit: 2048
86
  end
J
Jeremy Kemper 已提交
87

88
  create_table :birds, force: true do |t|
89
    t.string :name
90
    t.string :color
91 92 93
    t.integer :pirate_id
  end

94
  create_table :books, force: true do |t|
95
    t.integer :author_id
96
    t.column :name, :string
97
    t.column :status, :integer, default: 0
Y
Yury Korolev 已提交
98
    t.column :read_status, :integer, default: 0
99
  end
J
Jeremy Kemper 已提交
100

101
  create_table :booleans, force: true do |t|
102
    t.boolean :value
103
    t.boolean :has_fun, null: false, default: false
104
  end
J
Jeremy Kemper 已提交
105

106
  create_table :bulbs, force: true do |t|
107 108
    t.integer :car_id
    t.string  :name
109
    t.boolean :frickinawesome
110
    t.string :color
111 112
  end

113
  create_table "CamelCase", force: true do |t|
114 115 116
    t.string :name
  end

117
  create_table :cars, force: true do |t|
118 119 120
    t.string  :name
    t.integer :engines_count
    t.integer :wheels_count
121
    t.column :lock_version, :integer, null: false, default: 0
122
    t.timestamps
123 124
  end

125 126
  create_table :categories, force: true do |t|
    t.string :name, null: false
127
    t.string :type
128
    t.integer :categorizations_count
129
  end
J
Jeremy Kemper 已提交
130

131 132 133
  create_table :categories_posts, force: true, id: false do |t|
    t.integer :category_id, null: false
    t.integer :post_id, null: false
134
  end
135

136
  create_table :categorizations, force: true do |t|
137
    t.column :category_id, :integer
138
    t.string :named_category_name
139 140
    t.column :post_id, :integer
    t.column :author_id, :integer
141
    t.column :special, :boolean
142
  end
J
Jeremy Kemper 已提交
143

144
  create_table :citations, force: true do |t|
145 146 147
    t.column :book1_id, :integer
    t.column :book2_id, :integer
  end
148

149
  create_table :clubs, force: true do |t|
150
    t.string :name
151
    t.integer :category_id
152
  end
J
Jeremy Kemper 已提交
153

154
  create_table :collections, force: true do |t|
155 156 157
    t.string :name
  end

158 159
  create_table :colnametests, force: true do |t|
    t.integer :references, null: false
160
  end
J
Jeremy Kemper 已提交
161

162 163
  create_table :comments, force: true do |t|
    t.integer :post_id, null: false
164 165 166
    # 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)
167
      t.string  :body, null: false, limit: 4000
168
    else
169
      t.text    :body, null: false
170
    end
171
    t.string  :type
172 173
    t.integer :taggings_count, default: 0
    t.integer :children_count, default: 0
174
    t.integer :parent_id
175
  end
176

177
  create_table :companies, force: true do |t|
178 179
    t.string  :type
    t.integer :firm_id
180
    t.string  :firm_name
181 182
    t.string  :name
    t.integer :client_of
183
    t.integer :rating, default: 1
184
    t.integer :account_id
185
    t.string :description, default: ""
186
  end
187

188 189 190
  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
191

192
  create_table :vegetables, force: true do |t|
193
    t.string :name
194
    t.integer :seller_id
195 196 197
    t.string :custom_type
  end

198 199 200
  create_table :computers, force: true do |t|
    t.integer :developer, null: false
    t.integer :extendedWarranty, null: false
201
  end
202

203
  create_table :contracts, force: true do |t|
204 205 206
    t.integer :developer_id
    t.integer :company_id
  end
207

208
  create_table :customers, force: true do |t|
209
    t.string  :name
210
    t.integer :balance, default: 0
211 212 213 214 215
    t.string  :address_street
    t.string  :address_city
    t.string  :address_country
    t.string  :gps_location
  end
216

217
  create_table :dashboards, force: true, id: false do |t|
218 219 220
    t.string :dashboard_id
    t.string :name
  end
221

222
  create_table :developers, force: true do |t|
223
    t.string   :name
224
    t.integer  :salary, default: 70000
225 226
    t.datetime :created_at
    t.datetime :updated_at
227 228
    t.datetime :created_on
    t.datetime :updated_on
229
  end
230

231 232 233
  create_table :developers_projects, force: true, id: false do |t|
    t.integer :developer_id, null: false
    t.integer :project_id, null: false
234
    t.date    :joined_on
235
    t.integer :access_level, default: 1
236
  end
237

238 239 240 241
  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
242 243
  end

244
  create_table :dogs, force: true do |t|
245 246
    t.integer :trainer_id
    t.integer :breeder_id
247
    t.integer :dog_lover_id
248
    t.string  :alias
249 250
  end

251 252 253
  create_table :edges, force: true, id: false do |t|
    t.column :source_id, :integer, null: false
    t.column :sink_id,   :integer, null: false
254
  end
255
  add_index :edges, [:source_id, :sink_id], unique: true, name: 'unique_edge_index'
256

257
  create_table :engines, force: true do |t|
258 259
    t.integer :car_id
  end
260

261 262 263
  create_table :entrants, force: true do |t|
    t.string  :name, null: false
    t.integer :course_id, null: false
264
  end
265

266
  create_table :essays, force: true do |t|
267 268 269
    t.string :name
    t.string :writer_id
    t.string :writer_type
270 271
    t.string :category_id
    t.string :author_id
272 273
  end

274 275
  create_table :events, force: true do |t|
    t.string :title, limit: 5
276 277
  end

278
  create_table :eyes, force: true do |t|
279 280
  end

281
  create_table :funny_jokes, force: true do |t|
282
    t.string :name
283 284
  end

285
  create_table :cold_jokes, force: true do |t|
286 287 288
    t.string :name
  end

289
  create_table :friendships, force: true do |t|
290
    t.integer :friend_id
291
    t.integer :follower_id
292 293
  end

294 295
  create_table :goofy_string_id, force: true, id: false do |t|
    t.string :id, null: false
296 297 298
    t.string :info
  end

299
  create_table :having, force: true do |t|
300 301 302
    t.string :where
  end

303
  create_table :guids, force: true do |t|
304
    t.column :key, :string
305 306
  end

307 308 309
  create_table :inept_wizards, force: true do |t|
    t.column :name, :string, null: false
    t.column :city, :string, null: false
310
    t.column :type, :string
311 312
  end

313
  create_table :integer_limits, force: true do |t|
314 315
    t.integer :"c_int_without_limit"
    (1..8).each do |i|
316
      t.integer :"c_int_#{i}", limit: i
317 318 319
    end
  end

320
  create_table :invoices, force: true do |t|
321 322 323 324
    t.integer :balance
    t.datetime :updated_at
  end

325
  create_table :iris, force: true do |t|
326 327 328 329
    t.references :eye
    t.string     :color
  end

330
  create_table :items, force: true do |t|
331 332
    t.column :name, :string
  end
333

334
  create_table :jobs, force: true do |t|
335 336 337
    t.integer :ideal_reference_id
  end

P
Pablo Torres 已提交
338
  create_table :keyboards, force: true, id: false do |t|
339 340
    t.primary_key :key_number
    t.string      :name
341 342
  end

343
  create_table :legacy_things, force: true do |t|
344
    t.integer :tps_report_number
345
    t.integer :version, null: false, default: 0
346 347
  end

348
  create_table :lessons, force: true do |t|
349 350 351
    t.string :name
  end

352
  create_table :lessons_students, id: false, force: true do |t|
353 354 355 356
    t.references :lesson
    t.references :student
  end

357
  create_table :lint_models, force: true
358

359
  create_table :line_items, force: true do |t|
360 361 362 363
    t.integer :invoice_id
    t.integer :amount
  end

364
  create_table :lock_without_defaults, force: true do |t|
365 366
    t.column :lock_version, :integer
  end
367

368
  create_table :lock_without_defaults_cust, force: true do |t|
369
    t.column :custom_lock_version, :integer
370
  end
371

372
  create_table :mateys, id: false, force: true do |t|
373 374 375
    t.column :pirate_id, :integer
    t.column :target_id, :integer
    t.column :weight, :integer
376
  end
J
Jeremy Kemper 已提交
377

378
  create_table :members, force: true do |t|
379
    t.string :name
380
    t.integer :member_type_id
J
Jeremy Kemper 已提交
381 382
  end

383
  create_table :member_details, force: true do |t|
384 385 386 387 388
    t.integer :member_id
    t.integer :organization_id
    t.string :extra_data
  end

389
  create_table :member_friends, force: true, id: false do |t|
390 391 392 393
    t.integer :member_id
    t.integer :friend_id
  end

394
  create_table :memberships, force: true do |t|
395 396
    t.datetime :joined_on
    t.integer :club_id, :member_id
397
    t.boolean :favourite, default: false
398
    t.string :type
J
Jeremy Kemper 已提交
399
  end
400

401
  create_table :member_types, force: true do |t|
402 403 404
    t.string :name
  end

405
  create_table :minivans, force: true, id: false do |t|
406 407 408
    t.string :minivan_id
    t.string :name
    t.string :speedometer_id
409
    t.string :color
410
  end
411

412
  create_table :minimalistics, force: true do |t|
413
  end
J
Jeremy Kemper 已提交
414

415
  create_table :mixed_case_monkeys, force: true, id: false do |t|
416 417
    t.primary_key :monkeyID
    t.integer     :fleaCount
418
  end
J
Jeremy Kemper 已提交
419

420
  create_table :mixins, force: true do |t|
421 422 423 424 425 426 427 428
    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
429
  end
430

431
  create_table :movies, force: true, id: false do |t|
432 433
    t.primary_key :movieid
    t.string      :name
434
  end
J
Jeremy Kemper 已提交
435

436 437 438 439 440 441
  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
442
    t.float   :temperature
443
    # Oracle/SQLServer supports precision up to 38
444
    if current_adapter?(:OracleAdapter, :SQLServerAdapter)
445
      t.decimal :atoms_in_universe, precision: 38, scale: 0
446
    else
447
      t.decimal :atoms_in_universe, precision: 55, scale: 0
448
    end
449
  end
450

451
  create_table :orders, force: true do |t|
452 453 454
    t.string  :name
    t.integer :billing_customer_id
    t.integer :shipping_customer_id
455
  end
456

457
  create_table :organizations, force: true do |t|
458 459 460
    t.string :name
  end

461
  create_table :owners, primary_key: :owner_id, force: true do |t|
462
    t.string :name
463 464
    t.column :updated_at, :datetime
    t.column :happy_at,   :datetime
465
    t.string :essay_id
466 467
  end

468
  create_table :paint_colors, force: true do |t|
469
    t.integer :non_poly_one_id
470 471
  end

472
  create_table :paint_textures, force: true do |t|
473
    t.integer :non_poly_two_id
474
  end
475

476
  create_table :parrots, force: true do |t|
477
    t.column :name, :string
478
    t.column :color, :string
479 480
    t.column :parrot_sti_class, :string
    t.column :killer_id, :integer
481 482 483 484 485 486
    t.column :created_at, :datetime
    t.column :created_on, :datetime
    t.column :updated_at, :datetime
    t.column :updated_on, :datetime
  end

487
  create_table :parrots_pirates, id: false, force: true do |t|
488 489 490 491
    t.column :parrot_id, :integer
    t.column :pirate_id, :integer
  end

492
  create_table :parrots_treasures, id: false, force: true do |t|
493 494 495
    t.column :parrot_id, :integer
    t.column :treasure_id, :integer
  end
496

497 498
  create_table :people, force: true do |t|
    t.string     :first_name, null: false
499
    t.references :primary_contact
500
    t.string     :gender, limit: 1
501
    t.references :number1_fan
502
    t.integer    :lock_version, null: false, default: 0
503
    t.string     :comments
504 505
    t.integer    :followers_count, default: 0
    t.integer    :friends_too_count, default: 0
506 507
    t.references :best_friend
    t.references :best_friend_of
508
    t.integer    :insures, null: false, default: 0
509
    t.timestamps
510
  end
J
Jon Leighton 已提交
511

512
  create_table :peoples_treasures, id: false, force: true do |t|
513 514 515
    t.column :rich_person_id, :integer
    t.column :treasure_id, :integer
  end
516

517
  create_table :pets, primary_key: :pet_id, force: true do |t|
518
    t.string :name
519
    t.integer :owner_id, :integer
520
    t.timestamps
521
  end
522

523
  create_table :pirates, force: true do |t|
524 525
    t.column :catchphrase, :string
    t.column :parrot_id, :integer
526
    t.integer :non_validated_parrot_id
527 528
    t.column :created_on, :datetime
    t.column :updated_on, :datetime
529
  end
530

531
  create_table :posts, force: true do |t|
532
    t.integer :author_id
533
    t.string  :title, null: false
534 535 536
    # 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)
537
      t.string  :body, null: false, limit: 4000
538
    else
539
      t.text    :body, null: false
540
    end
541
    t.string  :type
542 543 544 545 546 547 548
    t.integer :comments_count, default: 0
    t.integer :taggings_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
549
  end
550

551
  create_table :price_estimates, force: true do |t|
552 553 554 555
    t.string :estimate_of_type
    t.integer :estimate_of_id
    t.integer :price
  end
556

557
  create_table :products, force: true do |t|
558 559 560 561
    t.references :collection
    t.string     :name
  end

562
  create_table :projects, force: true do |t|
563 564 565 566
    t.string :name
    t.string :type
  end

567
  create_table :randomly_named_table, force: true do |t|
568 569 570 571
    t.string  :some_attribute
    t.integer :another_attribute
  end

572
  create_table :ratings, force: true do |t|
573 574 575 576
    t.integer :comment_id
    t.integer :value
  end

577 578 579 580
  create_table :readers, force: true do |t|
    t.integer :post_id, null: false
    t.integer :person_id, null: false
    t.boolean :skimmer, default: false
581
    t.integer :first_post_id
582 583
  end

584
  create_table :references, force: true do |t|
585 586 587
    t.integer :person_id
    t.integer :job_id
    t.boolean :favourite
588
    t.integer :lock_version, default: 0
589 590
  end

591
  create_table :shape_expressions, force: true do |t|
592 593 594 595 596
    t.string  :paint_type
    t.integer :paint_id
    t.string  :shape_type
    t.integer :shape_id
  end
597

598
  create_table :ships, force: true do |t|
599
    t.string :name
600
    t.integer :pirate_id
601
    t.integer :update_only_pirate_id
602 603 604 605
    t.datetime :created_at
    t.datetime :created_on
    t.datetime :updated_at
    t.datetime :updated_on
606
  end
607

608
  create_table :ship_parts, force: true do |t|
609 610 611
    t.string :name
    t.integer :ship_id
  end
612

613
  create_table :speedometers, force: true, id: false do |t|
614 615 616 617
    t.string :speedometer_id
    t.string :name
    t.string :dashboard_id
  end
618

619
  create_table :sponsors, force: true do |t|
620 621
    t.integer :club_id
    t.integer :sponsorable_id
622
    t.string :sponsorable_type
623
  end
624

625
  create_table :string_key_objects, id: false, primary_key: :id, force: true do |t|
626 627
    t.string     :id
    t.string     :name
628
    t.integer    :lock_version, null: false, default: 0
629 630
  end

631
  create_table :students, force: true do |t|
632 633 634
    t.string :name
  end

635 636
  create_table :subscribers, force: true, id: false do |t|
    t.string :nick, null: false
637
    t.string :name
638
    t.column :books_count, :integer, null: false, default: 0
639
  end
640
  add_index :subscribers, :nick, unique: true
641

642
  create_table :subscriptions, force: true do |t|
643 644 645 646
    t.string :subscriber_id
    t.integer :book_id
  end

647
  create_table :tags, force: true do |t|
648
    t.column :name, :string
649
    t.column :taggings_count, :integer, default: 0
650 651
  end

652
  create_table :taggings, force: true do |t|
653 654 655 656
    t.column :tag_id, :integer
    t.column :super_tag_id, :integer
    t.column :taggable_type, :string
    t.column :taggable_id, :integer
657
    t.string :comment
658 659
  end

660
  create_table :tasks, force: true do |t|
661 662
    t.datetime :starting
    t.datetime :ending
663 664
  end

665
  create_table :topics, force: true do |t|
666 667 668 669 670 671
    t.string   :title
    t.string   :author_name
    t.string   :author_email_address
    t.datetime :written_on
    t.time     :bonus_time
    t.date     :last_read
672 673 674
    # 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)
675 676
      t.string   :content, limit: 4000
      t.string   :important, limit: 4000
677 678
    else
      t.text     :content
A
Alvaro Bautista 已提交
679
      t.text     :important
680
    end
681 682 683
    t.boolean  :approved, default: true
    t.integer  :replies_count, default: 0
    t.integer  :unique_replies_count, default: 0
684
    t.integer  :parent_id
685
    t.string   :parent_title
686
    t.string   :type
687
    t.string   :group
P
Pratik Naik 已提交
688
    t.timestamps
689 690
  end

691
  create_table :toys, primary_key: :toy_id, force: true do |t|
692 693
    t.string :name
    t.integer :pet_id, :integer
694
    t.timestamps
695 696
  end

697
  create_table :traffic_lights, force: true do |t|
698 699
    t.string   :location
    t.string   :state
700
    t.text     :long_state, null: false
701 702 703 704
    t.datetime :created_at
    t.datetime :updated_at
  end

705
  create_table :treasures, force: true do |t|
706
    t.column :name, :string
707
    t.column :type, :string
708 709 710 711
    t.column :looter_id, :integer
    t.column :looter_type, :string
  end

712
  create_table :tyres, force: true do |t|
713 714 715
    t.integer :car_id
  end

716
  create_table :variants, force: true do |t|
717 718 719 720
    t.references :product
    t.string     :name
  end

721
  create_table :vertices, force: true do |t|
722 723 724
    t.column :label, :string
  end

725
  create_table 'warehouse-things', force: true do |t|
726 727 728 729
    t.integer :value
  end

  [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
730
    create_table(t, force: true) { }
731 732
  end

733
  # NOTE - the following 4 tables are used by models that have :inverse_of options on the associations
734
  create_table :men, force: true do |t|
735 736 737
    t.string  :name
  end

738
  create_table :faces, force: true do |t|
739 740
    t.string  :description
    t.integer :man_id
741
    t.integer :polymorphic_man_id
742 743 744
    t.string  :polymorphic_man_type
    t.integer :horrible_polymorphic_man_id
    t.string  :horrible_polymorphic_man_type
745 746
  end

747
  create_table :interests, force: true do |t|
748 749
    t.string :topic
    t.integer :man_id
750 751
    t.integer :polymorphic_man_id
    t.string :polymorphic_man_type
752 753 754
    t.integer :zine_id
  end

755 756
  create_table :wheels, force: true do |t|
    t.references :wheelable, polymorphic: true
757 758
  end

759
  create_table :zines, force: true do |t|
760 761 762
    t.string :title
  end

763
  create_table :countries, force: true, id: false, primary_key: 'country_id' do |t|
764 765 766
    t.string :country_id
    t.string :name
  end
767
  create_table :treaties, force: true, id: false, primary_key: 'treaty_id' do |t|
768 769 770
    t.string :treaty_id
    t.string :name
  end
771 772 773
  create_table :countries_treaties, force: true, id: false do |t|
    t.string :country_id, null: false
    t.string :treaty_id, null: false
774 775
  end

776
  create_table :liquid, force: true do |t|
777 778
    t.string :name
  end
779
  create_table :molecules, force: true do |t|
780 781 782
    t.integer :liquid_id
    t.string :name
  end
783
  create_table :electrons, force: true do |t|
784 785 786
    t.integer :molecule_id
    t.string :name
  end
787
  create_table :weirds, force: true do |t|
788
    t.string 'a$b'
A
Aaron Patterson 已提交
789
    t.string 'なまえ'
790
    t.string 'from'
791
  end
792

793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808
  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


809 810
  except 'SQLite' do
    # fk_test_has_fk should be before fk_test_has_pk
811 812
    create_table :fk_test_has_fk, force: true do |t|
      t.integer :fk_id, null: false
813 814
    end

815
    create_table :fk_test_has_pk, force: true do |t|
816 817 818
    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'})"
819 820

    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'})"
821
  end
822
end
823

824 825
Course.connection.create_table :courses, force: true do |t|
  t.column :name, :string, null: false
R
Rick Martinez 已提交
826 827 828
  t.column :college_id, :integer
end

829 830
College.connection.create_table :colleges, force: true do |t|
  t.column :name, :string, null: false
831
end