schema.rb 22.9 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
  when "PostgreSQL"
13
    enable_extension!('uuid-ossp', ActiveRecord::Base.connection)
14 15 16 17 18 19 20
    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
86

87
  add_foreign_key :authors, :author_addresses
J
Jeremy Kemper 已提交
88

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

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

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

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

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

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

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

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

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

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

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

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

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

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

173
  create_table :collections, force: true do |t|
174 175 176
    t.string :name
  end

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

181 182 183 184
  create_table :columns, force: true do |t|
    t.references :record
  end

185 186
  create_table :comments, force: true do |t|
    t.integer :post_id, null: false
187 188 189
    # 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)
190
      t.string  :body, null: false, limit: 4000
191
    else
192
      t.text    :body, null: false
193
    end
194
    t.string  :type
195
    t.integer :tags_count, default: 0
196
    t.integer :children_count, default: 0
197
    t.integer :parent_id
198 199 200
    t.references :author, polymorphic: true
    t.string :resource_id
    t.string :resource_type
201
    t.integer :developer_id
202
  end
203

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

215 216 217
  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
218

219
  create_table :vegetables, force: true do |t|
220
    t.string :name
221
    t.integer :seller_id
222 223 224
    t.string :custom_type
  end

225
  create_table :computers, force: true do |t|
226
    t.string :system
227 228
    t.integer :developer, null: false
    t.integer :extendedWarranty, null: false
229
  end
230

231 232 233 234 235
  create_table :computers_developers, id: false, force: true do |t|
    t.references :computer
    t.references :developer
  end

236
  create_table :contracts, force: true do |t|
237 238 239
    t.integer :developer_id
    t.integer :company_id
  end
240

241
  create_table :customers, force: true do |t|
242
    t.string  :name
243
    t.integer :balance, default: 0
244 245 246 247 248
    t.string  :address_street
    t.string  :address_city
    t.string  :address_country
    t.string  :gps_location
  end
249

250
  create_table :dashboards, force: true, id: false do |t|
251 252 253
    t.string :dashboard_id
    t.string :name
  end
254

255
  create_table :developers, force: true do |t|
256
    t.string   :name
257
    t.integer  :salary, default: 70000
258 259
    t.datetime :created_at
    t.datetime :updated_at
260 261
    t.datetime :created_on
    t.datetime :updated_on
262
  end
263

264 265 266
  create_table :developers_projects, force: true, id: false do |t|
    t.integer :developer_id, null: false
    t.integer :project_id, null: false
267
    t.date    :joined_on
268
    t.integer :access_level, default: 1
269
  end
270

271 272 273 274
  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
275 276
  end

277
  create_table :dogs, force: true do |t|
278 279
    t.integer :trainer_id
    t.integer :breeder_id
280
    t.integer :dog_lover_id
281
    t.string  :alias
282 283
  end

284 285 286
  create_table :edges, force: true, id: false do |t|
    t.column :source_id, :integer, null: false
    t.column :sink_id,   :integer, null: false
287
  end
288
  add_index :edges, [:source_id, :sink_id], unique: true, name: 'unique_edge_index'
289

290
  create_table :engines, force: true do |t|
291 292
    t.integer :car_id
  end
293

294 295 296
  create_table :entrants, force: true do |t|
    t.string  :name, null: false
    t.integer :course_id, null: false
297
  end
298

299
  create_table :essays, force: true do |t|
300 301 302
    t.string :name
    t.string :writer_id
    t.string :writer_type
303 304
    t.string :category_id
    t.string :author_id
305 306
  end

307 308
  create_table :events, force: true do |t|
    t.string :title, limit: 5
309 310
  end

311
  create_table :eyes, force: true do |t|
312 313
  end

314
  create_table :funny_jokes, force: true do |t|
315
    t.string :name
316 317
  end

318
  create_table :cold_jokes, force: true do |t|
S
💣  
Sean Griffin 已提交
319
    t.string :cold_name
320 321
  end

322
  create_table :friendships, force: true do |t|
323
    t.integer :friend_id
324
    t.integer :follower_id
325 326
  end

327 328
  create_table :goofy_string_id, force: true, id: false do |t|
    t.string :id, null: false
329 330 331
    t.string :info
  end

332
  create_table :having, force: true do |t|
333 334 335
    t.string :where
  end

336
  create_table :guids, force: true do |t|
337
    t.column :key, :string
338 339
  end

340 341 342
  create_table :inept_wizards, force: true do |t|
    t.column :name, :string, null: false
    t.column :city, :string, null: false
343
    t.column :type, :string
344 345
  end

346
  create_table :integer_limits, force: true do |t|
347 348
    t.integer :"c_int_without_limit"
    (1..8).each do |i|
349
      t.integer :"c_int_#{i}", limit: i
350 351 352
    end
  end

353
  create_table :invoices, force: true do |t|
354 355 356 357
    t.integer :balance
    t.datetime :updated_at
  end

358
  create_table :iris, force: true do |t|
359 360 361 362
    t.references :eye
    t.string     :color
  end

363
  create_table :items, force: true do |t|
364 365
    t.column :name, :string
  end
366

367
  create_table :jobs, force: true do |t|
368 369 370
    t.integer :ideal_reference_id
  end

P
Pablo Torres 已提交
371
  create_table :keyboards, force: true, id: false do |t|
372 373
    t.primary_key :key_number
    t.string      :name
374 375
  end

376
  create_table :legacy_things, force: true do |t|
377
    t.integer :tps_report_number
378
    t.integer :version, null: false, default: 0
379 380
  end

381
  create_table :lessons, force: true do |t|
382 383 384
    t.string :name
  end

385
  create_table :lessons_students, id: false, force: true do |t|
386 387 388 389
    t.references :lesson
    t.references :student
  end

390
  create_table :lint_models, force: true
391

392
  create_table :line_items, force: true do |t|
393 394 395 396
    t.integer :invoice_id
    t.integer :amount
  end

397
  create_table :lock_without_defaults, force: true do |t|
398 399
    t.column :lock_version, :integer
  end
400

401
  create_table :lock_without_defaults_cust, force: true do |t|
402
    t.column :custom_lock_version, :integer
403
  end
404

405 406 407
  create_table :magazines, force: true do |t|
  end

408
  create_table :mateys, id: false, force: true do |t|
409 410 411
    t.column :pirate_id, :integer
    t.column :target_id, :integer
    t.column :weight, :integer
412
  end
J
Jeremy Kemper 已提交
413

414
  create_table :members, force: true do |t|
415
    t.string :name
416
    t.integer :member_type_id
J
Jeremy Kemper 已提交
417 418
  end

419
  create_table :member_details, force: true do |t|
420 421 422 423 424
    t.integer :member_id
    t.integer :organization_id
    t.string :extra_data
  end

425
  create_table :member_friends, force: true, id: false do |t|
426 427 428 429
    t.integer :member_id
    t.integer :friend_id
  end

430
  create_table :memberships, force: true do |t|
431 432
    t.datetime :joined_on
    t.integer :club_id, :member_id
433
    t.boolean :favourite, default: false
434
    t.string :type
J
Jeremy Kemper 已提交
435
  end
436

437
  create_table :member_types, force: true do |t|
438 439 440
    t.string :name
  end

441
  create_table :minivans, force: true, id: false do |t|
442 443 444
    t.string :minivan_id
    t.string :name
    t.string :speedometer_id
445
    t.string :color
446
  end
447

448
  create_table :minimalistics, force: true do |t|
449
  end
J
Jeremy Kemper 已提交
450

451
  create_table :mixed_case_monkeys, force: true, id: false do |t|
452 453
    t.primary_key :monkeyID
    t.integer     :fleaCount
454
  end
J
Jeremy Kemper 已提交
455

456
  create_table :mixins, force: true do |t|
457 458 459 460 461 462 463 464
    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
465
  end
466

467
  create_table :movies, force: true, id: false do |t|
468 469
    t.primary_key :movieid
    t.string      :name
470
  end
J
Jeremy Kemper 已提交
471

472 473 474 475 476 477
  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
478
    t.float   :temperature
479
    # Oracle/SQLServer supports precision up to 38
480
    if current_adapter?(:OracleAdapter, :SQLServerAdapter)
481
      t.decimal :atoms_in_universe, precision: 38, scale: 0
482
    else
483
      t.decimal :atoms_in_universe, precision: 55, scale: 0
484
    end
485
  end
486

487
  create_table :orders, force: true do |t|
488 489 490
    t.string  :name
    t.integer :billing_customer_id
    t.integer :shipping_customer_id
491
  end
492

493
  create_table :organizations, force: true do |t|
494 495 496
    t.string :name
  end

497
  create_table :owners, primary_key: :owner_id, force: true do |t|
498
    t.string :name
499 500
    t.column :updated_at, :datetime
    t.column :happy_at,   :datetime
501
    t.string :essay_id
502 503
  end

504
  create_table :paint_colors, force: true do |t|
505
    t.integer :non_poly_one_id
506 507
  end

508
  create_table :paint_textures, force: true do |t|
509
    t.integer :non_poly_two_id
510
  end
511

512
  create_table :parrots, force: true do |t|
513
    t.column :name, :string
514
    t.column :color, :string
515 516
    t.column :parrot_sti_class, :string
    t.column :killer_id, :integer
517 518 519 520 521 522
    t.column :created_at, :datetime
    t.column :created_on, :datetime
    t.column :updated_at, :datetime
    t.column :updated_on, :datetime
  end

523
  create_table :parrots_pirates, id: false, force: true do |t|
524 525 526 527
    t.column :parrot_id, :integer
    t.column :pirate_id, :integer
  end

528
  create_table :parrots_treasures, id: false, force: true do |t|
529 530 531
    t.column :parrot_id, :integer
    t.column :treasure_id, :integer
  end
532

533 534
  create_table :people, force: true do |t|
    t.string     :first_name, null: false
535
    t.references :primary_contact
536
    t.string     :gender, limit: 1
537
    t.references :number1_fan
538
    t.integer    :lock_version, null: false, default: 0
539
    t.string     :comments
540 541
    t.integer    :followers_count, default: 0
    t.integer    :friends_too_count, default: 0
542 543
    t.references :best_friend
    t.references :best_friend_of
544
    t.integer    :insures, null: false, default: 0
545
    t.timestamp :born_at
546
    t.timestamps null: false
547
  end
J
Jon Leighton 已提交
548

549
  create_table :peoples_treasures, id: false, force: true do |t|
550 551 552
    t.column :rich_person_id, :integer
    t.column :treasure_id, :integer
  end
553

554 555 556 557 558 559
  create_table :personal_legacy_things, force: true do |t|
    t.integer :tps_report_number
    t.integer :person_id
    t.integer :version, null: false, default: 0
  end

560
  create_table :pets, primary_key: :pet_id, force: true do |t|
561
    t.string :name
562
    t.integer :owner_id, :integer
563
    t.timestamps null: false
564
  end
565

566
  create_table :pirates, force: true do |t|
567 568
    t.column :catchphrase, :string
    t.column :parrot_id, :integer
569
    t.integer :non_validated_parrot_id
570 571
    t.column :created_on, :datetime
    t.column :updated_on, :datetime
572
  end
573

574
  create_table :posts, force: true do |t|
575
    t.integer :author_id
576
    t.string  :title, null: false
577 578 579
    # 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)
580
      t.string  :body, null: false, limit: 4000
581
    else
582
      t.text    :body, null: false
583
    end
584
    t.string  :type
585 586 587 588 589 590
    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
591
  end
592

593 594 595 596 597
  create_table :serialized_posts, force: true do |t|
    t.integer :author_id
    t.string :title, null: false
  end

598
  create_table :price_estimates, force: true do |t|
599 600 601 602
    t.string :estimate_of_type
    t.integer :estimate_of_id
    t.integer :price
  end
603

604
  create_table :products, force: true do |t|
605
    t.references :collection
606
    t.references :type
607 608 609
    t.string     :name
  end

610 611 612 613
  create_table :product_types, force: true do |t|
    t.string :name
  end

614
  create_table :projects, force: true do |t|
615 616 617 618
    t.string :name
    t.string :type
  end

619
  create_table :randomly_named_table, force: true do |t|
620 621 622 623
    t.string  :some_attribute
    t.integer :another_attribute
  end

624
  create_table :ratings, force: true do |t|
625 626 627 628
    t.integer :comment_id
    t.integer :value
  end

629 630 631 632
  create_table :readers, force: true do |t|
    t.integer :post_id, null: false
    t.integer :person_id, null: false
    t.boolean :skimmer, default: false
633
    t.integer :first_post_id
634 635
  end

636
  create_table :references, force: true do |t|
637 638 639
    t.integer :person_id
    t.integer :job_id
    t.boolean :favourite
640
    t.integer :lock_version, default: 0
641 642
  end

643
  create_table :shape_expressions, force: true do |t|
644 645 646 647 648
    t.string  :paint_type
    t.integer :paint_id
    t.string  :shape_type
    t.integer :shape_id
  end
649

650
  create_table :ships, force: true do |t|
651
    t.string :name
652
    t.integer :pirate_id
653
    t.integer :update_only_pirate_id
654 655 656 657
    t.datetime :created_at
    t.datetime :created_on
    t.datetime :updated_at
    t.datetime :updated_on
658
  end
659

660
  create_table :ship_parts, force: true do |t|
661 662 663
    t.string :name
    t.integer :ship_id
  end
664

665
  create_table :speedometers, force: true, id: false do |t|
666 667 668 669
    t.string :speedometer_id
    t.string :name
    t.string :dashboard_id
  end
670

671
  create_table :sponsors, force: true do |t|
672 673
    t.integer :club_id
    t.integer :sponsorable_id
674
    t.string :sponsorable_type
675
  end
676

677
  create_table :string_key_objects, id: false, primary_key: :id, force: true do |t|
678 679
    t.string     :id
    t.string     :name
680
    t.integer    :lock_version, null: false, default: 0
681 682
  end

683
  create_table :students, force: true do |t|
684
    t.string :name
685 686
    t.boolean :active
    t.integer :college_id
687 688
  end

689 690
  create_table :subscribers, force: true, id: false do |t|
    t.string :nick, null: false
691
    t.string :name
692
    t.column :books_count, :integer, null: false, default: 0
693
  end
694
  add_index :subscribers, :nick, unique: true
695

696
  create_table :subscriptions, force: true do |t|
697 698 699 700
    t.string :subscriber_id
    t.integer :book_id
  end

701
  create_table :tags, force: true do |t|
702
    t.column :name, :string
703
    t.column :taggings_count, :integer, default: 0
704 705
  end

706
  create_table :taggings, force: true do |t|
707 708 709 710
    t.column :tag_id, :integer
    t.column :super_tag_id, :integer
    t.column :taggable_type, :string
    t.column :taggable_id, :integer
711
    t.string :comment
712 713
  end

714
  create_table :tasks, force: true do |t|
715 716
    t.datetime :starting
    t.datetime :ending
717 718
  end

719
  create_table :topics, force: true do |t|
720
    t.string   :title, limit: 250
721 722
    t.string   :author_name
    t.string   :author_email_address
A
Arthur Neves 已提交
723 724 725 726 727
    if mysql_56?
      t.datetime :written_on, limit: 6
    else
      t.datetime :written_on
    end
728 729
    t.time     :bonus_time
    t.date     :last_read
730 731 732
    # 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)
733 734
      t.string   :content, limit: 4000
      t.string   :important, limit: 4000
735 736
    else
      t.text     :content
A
Alvaro Bautista 已提交
737
      t.text     :important
738
    end
739 740 741
    t.boolean  :approved, default: true
    t.integer  :replies_count, default: 0
    t.integer  :unique_replies_count, default: 0
742
    t.integer  :parent_id
743
    t.string   :parent_title
744
    t.string   :type
745
    t.string   :group
746
    t.timestamps null: true
747 748
  end

749
  create_table :toys, primary_key: :toy_id, force: true do |t|
750 751
    t.string :name
    t.integer :pet_id, :integer
752
    t.timestamps null: false
753 754
  end

755
  create_table :traffic_lights, force: true do |t|
756 757
    t.string   :location
    t.string   :state
758
    t.text     :long_state, null: false
759 760 761 762
    t.datetime :created_at
    t.datetime :updated_at
  end

763
  create_table :treasures, force: true do |t|
764
    t.column :name, :string
765
    t.column :type, :string
766 767 768 769
    t.column :looter_id, :integer
    t.column :looter_type, :string
  end

770
  create_table :tyres, force: true do |t|
771 772 773
    t.integer :car_id
  end

774
  create_table :variants, force: true do |t|
775 776 777 778
    t.references :product
    t.string     :name
  end

779
  create_table :vertices, force: true do |t|
780 781 782
    t.column :label, :string
  end

783
  create_table 'warehouse-things', force: true do |t|
784 785 786 787
    t.integer :value
  end

  [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
788
    create_table(t, force: true) { }
789 790
  end

791
  # NOTE - the following 4 tables are used by models that have :inverse_of options on the associations
792
  create_table :men, force: true do |t|
793 794 795
    t.string  :name
  end

796
  create_table :faces, force: true do |t|
797 798
    t.string  :description
    t.integer :man_id
799
    t.integer :polymorphic_man_id
800
    t.string  :polymorphic_man_type
801 802
    t.integer :poly_man_without_inverse_id
    t.string  :poly_man_without_inverse_type
803 804
    t.integer :horrible_polymorphic_man_id
    t.string  :horrible_polymorphic_man_type
805 806
  end

807
  create_table :interests, force: true do |t|
808 809
    t.string :topic
    t.integer :man_id
810 811
    t.integer :polymorphic_man_id
    t.string :polymorphic_man_type
812 813 814
    t.integer :zine_id
  end

815 816
  create_table :wheels, force: true do |t|
    t.references :wheelable, polymorphic: true
817 818
  end

819
  create_table :zines, force: true do |t|
820 821 822
    t.string :title
  end

823
  create_table :countries, force: true, id: false, primary_key: 'country_id' do |t|
824 825 826
    t.string :country_id
    t.string :name
  end
827
  create_table :treaties, force: true, id: false, primary_key: 'treaty_id' do |t|
828 829 830
    t.string :treaty_id
    t.string :name
  end
831 832 833
  create_table :countries_treaties, force: true, id: false do |t|
    t.string :country_id, null: false
    t.string :treaty_id, null: false
834 835
  end

836
  create_table :liquid, force: true do |t|
837 838
    t.string :name
  end
839
  create_table :molecules, force: true do |t|
840 841 842
    t.integer :liquid_id
    t.string :name
  end
843
  create_table :electrons, force: true do |t|
844 845 846
    t.integer :molecule_id
    t.string :name
  end
847
  create_table :weirds, force: true do |t|
848
    t.string 'a$b'
A
Aaron Patterson 已提交
849
    t.string 'なまえ'
850
    t.string 'from'
851
  end
852

853 854 855 856 857 858 859 860 861 862 863 864 865 866 867
  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

868 869
  create_table :records, force: true do |t|
  end
870

871 872
  except 'SQLite' do
    # fk_test_has_fk should be before fk_test_has_pk
873 874
    create_table :fk_test_has_fk, force: true do |t|
      t.integer :fk_id, null: false
875 876
    end

Y
Yves Senn 已提交
877
    create_table :fk_test_has_pk, force: true, primary_key: "pk_id" do |t|
878 879
    end

Y
Yves Senn 已提交
880 881
    add_foreign_key :fk_test_has_fk, :fk_test_has_pk, column: "fk_id", name: "fk_name", primary_key: "pk_id"
    add_foreign_key :lessons_students, :students
882
  end
883 884 885 886 887

  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
888
    t.string :string_with_default, default: 'the original default'
889
  end
890
end
891

892 893
Course.connection.create_table :courses, force: true do |t|
  t.column :name, :string, null: false
R
Rick Martinez 已提交
894 895 896
  t.column :college_id, :integer
end

897 898
College.connection.create_table :colleges, force: true do |t|
  t.column :name, :string, null: false
899
end