schema.rb 28.3 KB
Newer Older
1 2
# frozen_string_literal: true

3
ActiveRecord::Schema.define do
4 5 6 7 8 9 10
  # ------------------------------------------------------------------- #
  #                                                                     #
  #   Please keep these create table statements in alphabetical order   #
  #   unless the ordering matters.  In which case, define them below.   #
  #                                                                     #
  # ------------------------------------------------------------------- #

11
  create_table :accounts, force: true do |t|
12
    t.references :firm, index: false
13
    t.string  :firm_name
14 15
    t.integer :credit_limit
  end
16

17
  create_table :admin_accounts, force: true do |t|
18 19 20
    t.string :name
  end

21
  create_table :admin_users, force: true do |t|
22
    t.string :name
23
    t.string :settings, null: true, limit: 1024
24 25
    t.string :parent, null: true, limit: 1024
    t.string :spouse, null: true, limit: 1024
26 27
    # MySQL does not allow default values for blobs. Fake it out with a
    # big varchar below.
28
    t.string :preferences, null: true, default: "", limit: 1024
29 30
    t.string :json_data, null: true, limit: 1024
    t.string :json_data_empty, null: true, default: "", limit: 1024
31
    t.text :params
32 33 34
    t.references :account
  end

35
  create_table :aircraft, force: true do |t|
36
    t.string :name
37
    t.integer :wheels_count, default: 0, null: false
38 39
  end

40 41 42 43 44 45 46 47
  create_table :articles, force: true do |t|
  end

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

48 49 50 51 52
  create_table :articles_tags, force: true do |t|
    t.references :article
    t.references :tag
  end

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

59 60
  create_table :authors, force: true do |t|
    t.string :name, null: false
61 62
    t.references :author_address
    t.references :author_address_extra
63 64
    t.string :organization_id
    t.string :owned_essay_id
65
  end
66

67
  create_table :author_addresses, force: true do |t|
68
  end
69

70
  add_foreign_key :authors, :author_addresses
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.references :author
96
    t.string :format
97
    t.column :name, :string
98
    t.column :status, :integer, default: 0
Y
Yury Korolev 已提交
99
    t.column :read_status, :integer, default: 0
100
    t.column :nullable_status, :integer
101 102 103 104
    t.column :language, :integer, default: 0
    t.column :author_visibility, :integer, default: 0
    t.column :illustrator_visibility, :integer, default: 0
    t.column :font_size, :integer, default: 0
105
    t.column :difficulty, :integer, default: 0
106
    t.column :cover, :string, default: "hard"
107
  end
J
Jeremy Kemper 已提交
108

109
  create_table :booleans, force: true do |t|
110
    t.boolean :value
111
    t.boolean :has_fun, null: false, default: false
112
  end
J
Jeremy Kemper 已提交
113

114
  create_table :bulbs, primary_key: "ID", force: true do |t|
115 116
    t.integer :car_id
    t.string  :name
117
    t.boolean :frickinawesome, default: false
118
    t.string :color
119 120
  end

121
  create_table "CamelCase", force: true do |t|
122 123 124
    t.string :name
  end

125
  create_table :cars, force: true do |t|
126 127
    t.string  :name
    t.integer :engines_count
128
    t.integer :wheels_count, default: 0
129
    t.column :lock_version, :integer, null: false, default: 0
130
    t.timestamps null: false
131 132
  end

133 134 135
  create_table :old_cars, id: :integer, force: true do |t|
  end

136 137
  create_table :carriers, force: true

138 139
  create_table :categories, force: true do |t|
    t.string :name, null: false
140
    t.string :type
141
    t.integer :categorizations_count
142
  end
J
Jeremy Kemper 已提交
143

144 145 146
  create_table :categories_posts, force: true, id: false do |t|
    t.integer :category_id, null: false
    t.integer :post_id, null: false
147
  end
148

149
  create_table :categorizations, force: true do |t|
150
    t.column :category_id, :integer
151
    t.string :named_category_name
152 153
    t.column :post_id, :integer
    t.column :author_id, :integer
154
    t.column :special, :boolean
155
  end
J
Jeremy Kemper 已提交
156

157
  create_table :citations, force: true do |t|
158 159 160
    t.column :book1_id, :integer
    t.column :book2_id, :integer
  end
161

162
  create_table :clubs, force: true do |t|
163
    t.string :name
164
    t.integer :category_id
165
  end
J
Jeremy Kemper 已提交
166

167
  create_table :collections, force: true do |t|
168 169 170
    t.string :name
  end

171 172
  create_table :colnametests, force: true do |t|
    t.integer :references, null: false
173
  end
J
Jeremy Kemper 已提交
174

175 176 177 178
  create_table :columns, force: true do |t|
    t.references :record
  end

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

201
  create_table :companies, force: true do |t|
202
    t.string  :type
203
    t.references :firm, index: false
204
    t.string  :firm_name
205
    t.string  :name
206 207
    t.bigint :client_of
    t.bigint :rating, default: 1
208
    t.integer :account_id
209
    t.string :description, default: ""
210 211
    t.index [:name, :rating], order: :desc
    t.index [:name, :description], length: 10
212
    t.index [:firm_id, :type, :rating], name: "company_index", length: { type: 10 }, order: { rating: :desc }
213
    t.index [:firm_id, :type], name: "company_partial_index", where: "(rating > 10)"
214
    t.index :name, name: "company_name_index", using: :btree
215
    t.index "(CASE WHEN rating > 0 THEN lower(name) END)", name: "company_expression_index" if supports_expression_index?
216
  end
217

218 219 220 221 222 223 224 225
  create_table :content, force: true do |t|
    t.string :title
  end

  create_table :content_positions, force: true do |t|
    t.integer :content_id
  end

226
  create_table :vegetables, force: true do |t|
227
    t.string :name
228
    t.integer :seller_id
229 230 231
    t.string :custom_type
  end

232
  create_table :computers, force: true do |t|
233
    t.string :system
234 235
    t.integer :developer, null: false
    t.integer :extendedWarranty, null: false
236
  end
237

238 239 240 241 242
  create_table :computers_developers, id: false, force: true do |t|
    t.references :computer
    t.references :developer
  end

243
  create_table :contracts, force: true do |t|
244 245
    t.references :developer, index: false
    t.references :company, index: false
246
  end
247

248
  create_table :customers, force: true do |t|
249
    t.string  :name
250
    t.integer :balance, default: 0
251 252 253 254 255
    t.string  :address_street
    t.string  :address_city
    t.string  :address_country
    t.string  :gps_location
  end
256

257 258 259 260 261
  create_table :customer_carriers, force: true do |t|
    t.references :customer
    t.references :carrier
  end

262
  create_table :dashboards, force: true, id: false do |t|
263 264 265
    t.string :dashboard_id
    t.string :name
  end
266

267
  create_table :developers, force: true do |t|
268
    t.string   :name
269
    t.string   :first_name
270
    t.integer  :salary, default: 70000
271
    t.references :firm, index: false
272
    t.integer :mentor_id
273 274 275 276 277 278 279 280 281 282 283
    if subsecond_precision_supported?
      t.datetime :created_at, precision: 6
      t.datetime :updated_at, precision: 6
      t.datetime :created_on, precision: 6
      t.datetime :updated_on, precision: 6
    else
      t.datetime :created_at
      t.datetime :updated_at
      t.datetime :created_on
      t.datetime :updated_on
    end
284
  end
285

286 287 288
  create_table :developers_projects, force: true, id: false do |t|
    t.integer :developer_id, null: false
    t.integer :project_id, null: false
289
    t.date    :joined_on
290
    t.integer :access_level, default: 1
291
  end
292

293 294 295 296
  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
297 298
  end

299
  create_table :dogs, force: true do |t|
300 301
    t.integer :trainer_id
    t.integer :breeder_id
302
    t.integer :dog_lover_id
303
    t.string  :alias
304 305
  end

306 307 308 309 310
  create_table :doubloons, force: true do |t|
    t.integer :pirate_id
    t.integer :weight
  end

311 312 313
  create_table :edges, force: true, id: false do |t|
    t.column :source_id, :integer, null: false
    t.column :sink_id,   :integer, null: false
314
    t.index [:source_id, :sink_id], unique: true, name: "unique_edge_index"
315
  end
316

317
  create_table :engines, force: true do |t|
318
    t.references :car, index: false
319
  end
320

321 322 323
  create_table :entrants, force: true do |t|
    t.string  :name, null: false
    t.integer :course_id, null: false
324
  end
325

326
  create_table :essays, force: true do |t|
327 328 329
    t.string :name
    t.string :writer_id
    t.string :writer_type
330 331
    t.string :category_id
    t.string :author_id
332 333
  end

334 335
  create_table :events, force: true do |t|
    t.string :title, limit: 5
336 337
  end

338
  create_table :eyes, force: true do |t|
339 340
  end

341 342 343 344 345 346 347 348 349
  create_table :families, force: true do |t|
  end

  create_table :family_trees, force: true do |t|
    t.references :family
    t.references :member
    t.string :token
  end

350 351 352 353
  create_table :frogs, force: true do |t|
    t.string :name
  end

354
  create_table :funny_jokes, force: true do |t|
355
    t.string :name
356 357
  end

358
  create_table :cold_jokes, force: true do |t|
S
💣  
Sean Griffin 已提交
359
    t.string :cold_name
360 361
  end

362
  create_table :friendships, force: true do |t|
363
    t.integer :friend_id
364
    t.integer :follower_id
365 366
  end

367 368
  create_table :goofy_string_id, force: true, id: false do |t|
    t.string :id, null: false
369 370 371
    t.string :info
  end

372
  create_table :having, force: true do |t|
373 374 375
    t.string :where
  end

376
  create_table :guids, force: true do |t|
377
    t.column :key, :string
378 379
  end

Y
Yves Senn 已提交
380
  create_table :guitars, force: true do |t|
381 382 383
    t.string :color
  end

384 385 386
  create_table :inept_wizards, force: true do |t|
    t.column :name, :string, null: false
    t.column :city, :string, null: false
387
    t.column :type, :string
388 389
  end

390
  create_table :integer_limits, force: true do |t|
391 392
    t.integer :"c_int_without_limit"
    (1..8).each do |i|
393
      t.integer :"c_int_#{i}", limit: i
394 395 396
    end
  end

397
  create_table :invoices, force: true do |t|
398
    t.integer :balance
399 400 401 402 403
    if subsecond_precision_supported?
      t.datetime :updated_at, precision: 6
    else
      t.datetime :updated_at
    end
404 405
  end

406
  create_table :iris, force: true do |t|
407 408 409 410
    t.references :eye
    t.string     :color
  end

411
  create_table :items, force: true do |t|
412 413
    t.column :name, :string
  end
414

415
  create_table :jobs, force: true do |t|
416 417 418
    t.integer :ideal_reference_id
  end

419 420 421 422 423
  create_table :jobs_pool, force: true, id: false do |t|
    t.references :job, null: false, index: true
    t.references :user, null: false, index: true
  end

P
Pablo Torres 已提交
424
  create_table :keyboards, force: true, id: false do |t|
425 426
    t.primary_key :key_number
    t.string      :name
427 428
  end

429 430 431
  create_table :kitchens, force: true do |t|
  end

432
  create_table :legacy_things, force: true do |t|
433
    t.integer :tps_report_number
434
    t.integer :version, null: false, default: 0
435 436
  end

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

441
  create_table :lessons_students, id: false, force: true do |t|
442 443 444 445
    t.references :lesson
    t.references :student
  end

446 447 448 449 450 451 452 453
  create_table :students, force: true do |t|
    t.string :name
    t.boolean :active
    t.integer :college_id
  end

  add_foreign_key :lessons_students, :students, on_delete: :cascade

454
  create_table :lint_models, force: true
455

456
  create_table :line_items, force: true do |t|
457 458 459 460
    t.integer :invoice_id
    t.integer :amount
  end

461 462 463 464 465
  create_table :lions, force: true do |t|
    t.integer :gender
    t.boolean :is_vegetarian, default: false
  end

466
  create_table :lock_without_defaults, force: true do |t|
467
    t.column :title, :string
468
    t.column :lock_version, :integer
469
    t.timestamps null: true
470
  end
471

472
  create_table :lock_without_defaults_cust, force: true do |t|
473
    t.column :title, :string
474
    t.column :custom_lock_version, :integer
475
    t.timestamps null: true
476
  end
477

478 479 480
  create_table :magazines, force: true do |t|
  end

481
  create_table :mateys, id: false, force: true do |t|
482 483 484
    t.column :pirate_id, :integer
    t.column :target_id, :integer
    t.column :weight, :integer
485
  end
J
Jeremy Kemper 已提交
486

487
  create_table :members, force: true do |t|
488
    t.string :name
489
    t.integer :member_type_id
J
Jeremy Kemper 已提交
490 491
  end

492
  create_table :member_details, force: true do |t|
493 494 495 496 497
    t.integer :member_id
    t.integer :organization_id
    t.string :extra_data
  end

498
  create_table :member_friends, force: true, id: false do |t|
499 500 501 502
    t.integer :member_id
    t.integer :friend_id
  end

503
  create_table :memberships, force: true do |t|
504 505
    t.datetime :joined_on
    t.integer :club_id, :member_id
506
    t.boolean :favourite, default: false
507
    t.integer :type
J
Jeremy Kemper 已提交
508
  end
509

510
  create_table :member_types, force: true do |t|
511 512 513
    t.string :name
  end

514 515 516 517
  create_table :mentors, force: true do |t|
    t.string :name
  end

518
  create_table :minivans, force: true, id: false do |t|
519 520 521
    t.string :minivan_id
    t.string :name
    t.string :speedometer_id
522
    t.string :color
523
  end
524

525
  create_table :minimalistics, force: true do |t|
526
  end
J
Jeremy Kemper 已提交
527

528
  create_table :mixed_case_monkeys, force: true, id: false do |t|
529 530
    t.primary_key :monkeyID
    t.integer     :fleaCount
531
  end
J
Jeremy Kemper 已提交
532

533
  create_table :mixins, force: true do |t|
534 535 536 537 538 539 540 541
    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
542
  end
543

544
  create_table :movies, force: true, id: false do |t|
545 546
    t.primary_key :movieid
    t.string      :name
547
  end
M
Michael Ryan 已提交
548 549 550 551

  create_table :notifications, force: true do |t|
    t.string :message
  end
J
Jeremy Kemper 已提交
552

553 554 555
  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
B
bogdanvlviv 已提交
556
    t.decimal :world_population, precision: 20, scale: 0
557 558
    t.decimal :my_house_population, precision: 2, scale: 0
    t.decimal :decimal_number_with_default, precision: 3, scale: 2, default: 2.78
559
    t.float   :temperature
560
    # Oracle/SQLServer supports precision up to 38
561
    if current_adapter?(:OracleAdapter, :SQLServerAdapter)
562
      t.decimal :atoms_in_universe, precision: 38, scale: 0
R
Ray Zane 已提交
563 564
    elsif current_adapter?(:FbAdapter)
      t.decimal :atoms_in_universe, precision: 18, scale: 0
565
    else
566
      t.decimal :atoms_in_universe, precision: 55, scale: 0
567
    end
568
  end
569

570
  create_table :orders, force: true do |t|
571 572 573
    t.string  :name
    t.integer :billing_customer_id
    t.integer :shipping_customer_id
574
  end
575

576
  create_table :organizations, force: true do |t|
577 578 579
    t.string :name
  end

580
  create_table :owners, primary_key: :owner_id, force: true do |t|
581
    t.string :name
582 583 584 585 586
    if subsecond_precision_supported?
      t.column :updated_at, :datetime, precision: 6
    else
      t.column :updated_at, :datetime
    end
587
    t.column :happy_at,   :datetime
588
    t.string :essay_id
589 590
  end

591
  create_table :paint_colors, force: true do |t|
592
    t.integer :non_poly_one_id
593 594
  end

595
  create_table :paint_textures, force: true do |t|
596
    t.integer :non_poly_two_id
597
  end
598

599
  create_table :parrots, force: true do |t|
600
    t.column :name, :string
601
    t.column :color, :string
602 603
    t.column :parrot_sti_class, :string
    t.column :killer_id, :integer
604
    t.column :updated_count, :integer, default: 0
605 606 607 608 609 610 611 612 613 614 615
    if subsecond_precision_supported?
      t.column :created_at, :datetime, precision: 0
      t.column :created_on, :datetime, precision: 0
      t.column :updated_at, :datetime, precision: 0
      t.column :updated_on, :datetime, precision: 0
    else
      t.column :created_at, :datetime
      t.column :created_on, :datetime
      t.column :updated_at, :datetime
      t.column :updated_on, :datetime
    end
616 617
  end

618
  create_table :parrots_pirates, id: false, force: true do |t|
619 620 621 622
    t.column :parrot_id, :integer
    t.column :pirate_id, :integer
  end

623
  create_table :parrots_treasures, id: false, force: true do |t|
624 625 626
    t.column :parrot_id, :integer
    t.column :treasure_id, :integer
  end
627

628 629
  create_table :people, force: true do |t|
    t.string     :first_name, null: false
630
    t.references :primary_contact
631
    t.string     :gender, limit: 1
632
    t.references :number1_fan
633
    t.integer    :lock_version, null: false, default: 0
634
    t.string     :comments
635 636
    t.integer    :followers_count, default: 0
    t.integer    :friends_too_count, default: 0
637 638
    t.references :best_friend
    t.references :best_friend_of
639
    t.integer    :insures, null: false, default: 0
640
    t.timestamp :born_at
641
    t.timestamps null: false
642
  end
J
Jon Leighton 已提交
643

644
  create_table :peoples_treasures, id: false, force: true do |t|
645 646 647
    t.column :rich_person_id, :integer
    t.column :treasure_id, :integer
  end
648

649 650 651 652 653 654
  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

655
  create_table :pets, primary_key: :pet_id, force: true do |t|
656
    t.string :name
657
    t.integer :owner_id, :integer
658 659 660 661 662
    if subsecond_precision_supported?
      t.timestamps null: false, precision: 6
    else
      t.timestamps null: false
    end
663
  end
664

665 666 667 668 669 670
  create_table :pets_treasures, force: true do |t|
    t.column :treasure_id, :integer
    t.column :pet_id, :integer
    t.column :rainbow_color, :string
  end

671
  create_table :pirates, force: true do |t|
672 673
    t.column :catchphrase, :string
    t.column :parrot_id, :integer
674
    t.integer :non_validated_parrot_id
675 676 677 678 679 680 681
    if subsecond_precision_supported?
      t.column :created_on, :datetime, precision: 6
      t.column :updated_on, :datetime, precision: 6
    else
      t.column :created_on, :datetime
      t.column :updated_on, :datetime
    end
682
  end
683

684
  create_table :posts, force: true do |t|
685 686
    t.references :author
    t.string :title, null: false
687 688 689
    # 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)
690
      t.string  :body, null: false, limit: 4000
691
    else
692
      t.text    :body, null: false
693
    end
694
    t.string  :type
695 696 697 698
    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
699
    t.integer :indestructible_tags_count, default: 0
700 701
    t.integer :tags_with_destroy_count, default: 0
    t.integer :tags_with_nullify_count, default: 0
702
  end
703

704 705 706 707 708
  create_table :serialized_posts, force: true do |t|
    t.integer :author_id
    t.string :title, null: false
  end

709 710 711 712 713
  create_table :images, force: true do |t|
    t.integer :imageable_identifier
    t.string :imageable_class
  end

714
  create_table :price_estimates, force: true do |t|
715 716 717 718
    t.string :estimate_of_type
    t.integer :estimate_of_id
    t.integer :price
  end
719

720
  create_table :products, force: true do |t|
721
    t.references :collection
722
    t.references :type
723 724 725
    t.string     :name
  end

726 727 728 729
  create_table :product_types, force: true do |t|
    t.string :name
  end

730
  create_table :projects, force: true do |t|
731 732
    t.string :name
    t.string :type
733
    t.references :firm, index: false
734
    t.integer :mentor_id
735 736
  end

V
Vipul A M 已提交
737 738 739 740 741 742 743 744 745 746 747
  create_table :randomly_named_table1, force: true do |t|
    t.string  :some_attribute
    t.integer :another_attribute
  end

  create_table :randomly_named_table2, force: true do |t|
    t.string  :some_attribute
    t.integer :another_attribute
  end

  create_table :randomly_named_table3, force: true do |t|
748 749 750 751
    t.string  :some_attribute
    t.integer :another_attribute
  end

752
  create_table :ratings, force: true do |t|
753 754 755 756
    t.integer :comment_id
    t.integer :value
  end

757 758 759 760
  create_table :readers, force: true do |t|
    t.integer :post_id, null: false
    t.integer :person_id, null: false
    t.boolean :skimmer, default: false
761
    t.integer :first_post_id
762 763
  end

764
  create_table :references, force: true do |t|
765 766 767
    t.integer :person_id
    t.integer :job_id
    t.boolean :favourite
768
    t.integer :lock_version, default: 0
769 770
  end

771
  create_table :shape_expressions, force: true do |t|
772 773 774 775 776
    t.string  :paint_type
    t.integer :paint_id
    t.string  :shape_type
    t.integer :shape_id
  end
777

778
  create_table :ships, force: true do |t|
779
    t.string :name
780
    t.integer :pirate_id
781
    t.belongs_to :developer
782
    t.integer :update_only_pirate_id
783 784
    # Conventionally named column for counter_cache
    t.integer :treasures_count, default: 0
785 786 787 788
    t.datetime :created_at
    t.datetime :created_on
    t.datetime :updated_at
    t.datetime :updated_on
789
  end
790

791
  create_table :ship_parts, force: true do |t|
792 793
    t.string :name
    t.integer :ship_id
794 795 796 797 798
    if subsecond_precision_supported?
      t.datetime :updated_at, precision: 6
    else
      t.datetime :updated_at
    end
799
  end
800

801 802 803 804
  create_table :prisoners, force: true do |t|
    t.belongs_to :ship
  end

805 806 807 808
  create_table :sinks, force: true do |t|
    t.references :kitchen
  end

809 810 811 812 813
  create_table :shop_accounts, force: true do |t|
    t.references :customer
    t.references :customer_carrier
  end

814
  create_table :speedometers, force: true, id: false do |t|
815 816 817 818
    t.string :speedometer_id
    t.string :name
    t.string :dashboard_id
  end
819

820
  create_table :sponsors, force: true do |t|
821
    t.integer :club_id
822
    t.references :sponsorable, polymorphic: true, index: false
823
    t.references :sponsor, polymorphic: true, index: false
824
  end
825

826 827 828 829 830
  create_table :string_key_objects, id: false, force: true do |t|
    t.string :id, null: false
    t.string :name
    t.integer :lock_version, null: false, default: 0
    t.index :id, unique: true
831 832
  end

833
  create_table :subscribers, id: false, force: true do |t|
834
    t.string :nick, null: false
835
    t.string :name
836
    t.integer :id
837 838
    t.integer :books_count, null: false, default: 0
    t.integer :update_count, null: false, default: 0
839
    t.index :nick, unique: true
840 841
  end

842
  create_table :subscriptions, force: true do |t|
843 844 845 846
    t.string :subscriber_id
    t.integer :book_id
  end

847
  create_table :tags, force: true do |t|
848
    t.column :name, :string
849
    t.column :taggings_count, :integer, default: 0
850 851
  end

852
  create_table :taggings, force: true do |t|
853 854 855 856
    t.column :tag_id, :integer
    t.column :super_tag_id, :integer
    t.column :taggable_type, :string
    t.column :taggable_id, :integer
857
    t.string :comment
858
    t.string :type
859 860
  end

861
  create_table :tasks, force: true do |t|
862 863
    t.datetime :starting
    t.datetime :ending
864 865
  end

866
  create_table :topics, force: true do |t|
867
    t.string   :title, limit: 250
868 869
    t.string   :author_name
    t.string   :author_email_address
870
    if subsecond_precision_supported?
871
      t.datetime :written_on, precision: 6
A
Arthur Neves 已提交
872 873 874
    else
      t.datetime :written_on
    end
875 876
    t.time     :bonus_time
    t.date     :last_read
877 878 879
    # 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)
880 881
      t.string   :content, limit: 4000
      t.string   :important, limit: 4000
882 883
    else
      t.text     :content
A
Alvaro Bautista 已提交
884
      t.text     :important
885
    end
886 887 888
    t.boolean  :approved, default: true
    t.integer  :replies_count, default: 0
    t.integer  :unique_replies_count, default: 0
889
    t.integer  :parent_id
890
    t.string   :parent_title
891
    t.string   :type
892
    t.string   :group
893 894 895 896 897
    if subsecond_precision_supported?
      t.timestamps null: true, precision: 6
    else
      t.timestamps null: true
    end
898 899
  end

900
  create_table :toys, primary_key: :toy_id, force: true do |t|
901 902
    t.string :name
    t.integer :pet_id, :integer
903
    t.timestamps null: false
904 905
  end

906
  create_table :traffic_lights, force: true do |t|
907 908
    t.string   :location
    t.string   :state
909
    t.text     :long_state, null: false
910 911 912 913
    t.datetime :created_at
    t.datetime :updated_at
  end

914
  create_table :treasures, force: true do |t|
915
    t.column :name, :string
916
    t.column :type, :string
917 918
    t.column :looter_id, :integer
    t.column :looter_type, :string
919
    t.belongs_to :ship
920 921
  end

922 923 924 925 926
  create_table :tuning_pegs, force: true do |t|
    t.integer :guitar_id
    t.float :pitch
  end

927
  create_table :tyres, force: true do |t|
928 929 930
    t.integer :car_id
  end

931
  create_table :variants, force: true do |t|
932 933 934 935
    t.references :product
    t.string     :name
  end

936
  create_table :vertices, force: true do |t|
937 938 939
    t.column :label, :string
  end

940
  create_table "warehouse-things", force: true do |t|
941 942 943 944
    t.integer :value
  end

  [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
945
    create_table(t, force: true) {}
946 947
  end

948
  create_table :men, force: true do |t|
949 950 951
    t.string  :name
  end

952
  create_table :faces, force: true do |t|
953 954
    t.string  :description
    t.integer :man_id
955
    t.integer :polymorphic_man_id
956
    t.string  :polymorphic_man_type
957 958
    t.integer :poly_man_without_inverse_id
    t.string  :poly_man_without_inverse_type
959 960
    t.integer :horrible_polymorphic_man_id
    t.string  :horrible_polymorphic_man_type
961
    t.references :human, polymorphic: true, index: false
962 963
  end

964
  create_table :interests, force: true do |t|
965 966
    t.string :topic
    t.integer :man_id
967 968
    t.integer :polymorphic_man_id
    t.string :polymorphic_man_type
969 970 971
    t.integer :zine_id
  end

972
  create_table :zines, force: true do |t|
973 974 975
    t.string :title
  end

976
  create_table :wheels, force: true do |t|
977
    t.integer :size
978 979 980
    t.references :wheelable, polymorphic: true
  end

981
  create_table :countries, force: true, id: false, primary_key: "country_id" do |t|
982 983 984
    t.string :country_id
    t.string :name
  end
985
  create_table :treaties, force: true, id: false, primary_key: "treaty_id" do |t|
986 987 988
    t.string :treaty_id
    t.string :name
  end
989
  create_table :countries_treaties, force: true, primary_key: [:country_id, :treaty_id] do |t|
990 991
    t.string :country_id, null: false
    t.string :treaty_id, null: false
992 993
  end

994
  create_table :liquid, force: true do |t|
995 996
    t.string :name
  end
997
  create_table :molecules, force: true do |t|
998 999 1000
    t.integer :liquid_id
    t.string :name
  end
1001
  create_table :electrons, force: true do |t|
1002 1003 1004
    t.integer :molecule_id
    t.string :name
  end
1005
  create_table :weirds, force: true do |t|
1006 1007 1008
    t.string "a$b"
    t.string "なまえ"
    t.string "from"
1009
  end
1010

1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
  create_table :nodes, force: true do |t|
    t.integer :tree_id
    t.integer :parent_id
    t.string :name
    t.datetime :updated_at
  end
  create_table :trees, force: true do |t|
    t.string :name
    t.datetime :updated_at
  end

1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034
  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
1035 1036
    t.string :employable_list_type
    t.integer :employable_list_id
1037
  end
1038 1039 1040 1041
  create_table :recipes, force: true do |t|
    t.integer :chef_id
    t.integer :hotel_id
  end
1042

1043 1044
  create_table :records, force: true do |t|
  end
1045

1046 1047
  disable_referential_integrity do
    create_table :fk_test_has_pk, primary_key: "pk_id", force: :cascade do |t|
1048 1049
    end

1050 1051 1052
    create_table :fk_test_has_fk, force: true do |t|
      t.references :fk, null: false
      t.foreign_key :fk_test_has_pk, column: "fk_id", name: "fk_name", primary_key: "pk_id"
1053
    end
1054
  end
1055 1056 1057 1058 1059

  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
1060
    t.string :string_with_default, default: "the original default"
1061
  end
1062 1063 1064 1065 1066

  create_table :users, force: true do |t|
    t.string :token
    t.string :auth_token
  end
1067 1068 1069 1070

  create_table :test_with_keyword_column_name, force: true do |t|
    t.string :desc
  end
1071 1072 1073 1074

  create_table :non_primary_keys, force: true, id: false do |t|
    t.integer :id
  end
1075
end
1076

1077 1078
Course.connection.create_table :courses, force: true do |t|
  t.column :name, :string, null: false
R
Rick Martinez 已提交
1079 1080 1081
  t.column :college_id, :integer
end

1082 1083
College.connection.create_table :colleges, force: true do |t|
  t.column :name, :string, null: false
1084
end
1085 1086 1087 1088 1089 1090 1091 1092 1093

Professor.connection.create_table :professors, force: true do |t|
  t.column :name, :string, null: false
end

Professor.connection.create_table :courses_professors, id: false, force: true do |t|
  t.references :course
  t.references :professor
end
1094 1095

OtherDog.connection.create_table :dogs, force: true