schema.rb 27.0 KB
Newer Older
1
ActiveRecord::Schema.define do
2 3 4 5 6 7 8
  # ------------------------------------------------------------------- #
  #                                                                     #
  #   Please keep these create table statements in alphabetical order   #
  #   unless the ordering matters.  In which case, define them below.   #
  #                                                                     #
  # ------------------------------------------------------------------- #

9
  create_table :accounts, force: true do |t|
10
    t.integer :firm_id
11
    t.string  :firm_name
12 13
    t.integer :credit_limit
  end
14

15
  create_table :admin_accounts, force: true do |t|
16 17 18
    t.string :name
  end

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

31
  create_table :aircraft, force: true do |t|
32
    t.string :name
33
    t.integer :wheels_count, default: 0, null: false
34 35
  end

36 37 38 39 40 41 42 43
  create_table :articles, force: true do |t|
  end

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

44 45 46 47 48
  create_table :articles_tags, force: true do |t|
    t.references :article
    t.references :tag
  end

49 50 51
  create_table :audit_logs, force: true do |t|
    t.column :message, :string, null: false
    t.column :developer_id, :integer, null: false
52
    t.integer :unvalidated_developer_id
53
  end
54

55 56
  create_table :authors, force: true do |t|
    t.string :name, null: false
57 58
    t.integer :author_address_id
    t.integer :author_address_extra_id
59 60
    t.string :organization_id
    t.string :owned_essay_id
61
  end
62

63
  create_table :author_addresses, force: true do |t|
64
  end
65

66
  add_foreign_key :authors, :author_addresses
J
Jeremy Kemper 已提交
67

68
  create_table :author_favorites, force: true do |t|
69 70 71
    t.column :author_id, :integer
    t.column :favorite_author_id, :integer
  end
J
Jeremy Kemper 已提交
72

73
  create_table :auto_id_tests, force: true, id: false do |t|
74 75 76
    t.primary_key :auto_id
    t.integer     :value
  end
J
Jeremy Kemper 已提交
77

78
  create_table :binaries, force: true do |t|
79
    t.string :name
80
    t.binary :data
81
    t.binary :short_data, limit: 2048
82
  end
J
Jeremy Kemper 已提交
83

84
  create_table :birds, force: true do |t|
85
    t.string :name
86
    t.string :color
87 88 89
    t.integer :pirate_id
  end

90
  create_table :books, force: true do |t|
91
    t.integer :author_id
92
    t.string :format
93
    t.column :name, :string
94
    t.column :status, :integer, default: 0
Y
Yury Korolev 已提交
95
    t.column :read_status, :integer, default: 0
96
    t.column :nullable_status, :integer
97 98 99 100
    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
101
    t.column :difficulty, :integer, default: 0
102
    t.column :cover, :string, default: "hard"
103
  end
J
Jeremy Kemper 已提交
104

105
  create_table :booleans, force: true do |t|
106
    t.boolean :value
107
    t.boolean :has_fun, null: false, default: false
108
  end
J
Jeremy Kemper 已提交
109

110
  create_table :bulbs, force: true do |t|
111 112
    t.integer :car_id
    t.string  :name
113
    t.boolean :frickinawesome, default: false
114
    t.string :color
115 116
  end

117
  create_table "CamelCase", force: true do |t|
118 119 120
    t.string :name
  end

121
  create_table :cars, force: true do |t|
122 123 124
    t.string  :name
    t.integer :engines_count
    t.integer :wheels_count
125
    t.column :lock_version, :integer, null: false, default: 0
126
    t.timestamps null: false
127 128
  end

129 130
  create_table :carriers, force: true

131 132
  create_table :categories, force: true do |t|
    t.string :name, null: false
133
    t.string :type
134
    t.integer :categorizations_count
135
  end
J
Jeremy Kemper 已提交
136

137 138 139
  create_table :categories_posts, force: true, id: false do |t|
    t.integer :category_id, null: false
    t.integer :post_id, null: false
140
  end
141

142
  create_table :categorizations, force: true do |t|
143
    t.column :category_id, :integer
144
    t.string :named_category_name
145 146
    t.column :post_id, :integer
    t.column :author_id, :integer
147
    t.column :special, :boolean
148
  end
J
Jeremy Kemper 已提交
149

150
  create_table :citations, force: true do |t|
151 152 153
    t.column :book1_id, :integer
    t.column :book2_id, :integer
  end
154

155
  create_table :clubs, force: true do |t|
156
    t.string :name
157
    t.integer :category_id
158
  end
J
Jeremy Kemper 已提交
159

160
  create_table :collections, force: true do |t|
161 162 163
    t.string :name
  end

164 165
  create_table :colnametests, force: true do |t|
    t.integer :references, null: false
166
  end
J
Jeremy Kemper 已提交
167

168 169 170 171
  create_table :columns, force: true do |t|
    t.references :record
  end

172 173
  create_table :comments, force: true do |t|
    t.integer :post_id, null: false
174 175 176
    # 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)
177
      t.string  :body, null: false, limit: 4000
178
    else
179
      t.text    :body, null: false
180
    end
181
    t.string  :type
182
    t.integer :tags_count, default: 0
183
    t.integer :children_count, default: 0
184
    t.integer :parent_id
185 186 187
    t.references :author, polymorphic: true
    t.string :resource_id
    t.string :resource_type
188
    t.integer :developer_id
189
  end
190

191
  create_table :companies, force: true do |t|
192 193
    t.string  :type
    t.integer :firm_id
194
    t.string  :firm_name
195 196
    t.string  :name
    t.integer :client_of
197
    t.integer :rating, default: 1
198
    t.integer :account_id
199
    t.string :description, default: ""
200
    t.index [:firm_id, :type, :rating], name: "company_index", length: { type: 10 }, order: { rating: :desc }
201
    t.index [:firm_id, :type], name: "company_partial_index", where: "rating > 10"
202 203
    t.index :name, name: "company_name_index", using: :btree
    t.index "lower(name)", name: "company_expression_index" if supports_expression_index?
204
  end
205

206 207 208 209 210 211 212 213
  create_table :content, force: true do |t|
    t.string :title
  end

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

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

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

226 227 228 229 230
  create_table :computers_developers, id: false, force: true do |t|
    t.references :computer
    t.references :developer
  end

231
  create_table :contracts, force: true do |t|
232 233 234
    t.integer :developer_id
    t.integer :company_id
  end
235

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

245 246 247 248 249
  create_table :customer_carriers, force: true do |t|
    t.references :customer
    t.references :carrier
  end

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.string   :first_name
258
    t.integer  :salary, default: 70000
259
    t.integer :firm_id
260
    t.integer :mentor_id
261 262 263 264 265 266 267 268 269 270 271
    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
272
  end
273

274 275 276
  create_table :developers_projects, force: true, id: false do |t|
    t.integer :developer_id, null: false
    t.integer :project_id, null: false
277
    t.date    :joined_on
278
    t.integer :access_level, default: 1
279
  end
280

281 282 283 284
  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
285 286
  end

287
  create_table :dogs, force: true do |t|
288 289
    t.integer :trainer_id
    t.integer :breeder_id
290
    t.integer :dog_lover_id
291
    t.string  :alias
292 293
  end

294 295 296 297 298
  create_table :doubloons, force: true do |t|
    t.integer :pirate_id
    t.integer :weight
  end

299 300 301
  create_table :edges, force: true, id: false do |t|
    t.column :source_id, :integer, null: false
    t.column :sink_id,   :integer, null: false
302
    t.index [:source_id, :sink_id], unique: true, name: "unique_edge_index"
303
  end
304

305
  create_table :engines, force: true do |t|
306 307
    t.integer :car_id
  end
308

309 310 311
  create_table :entrants, force: true do |t|
    t.string  :name, null: false
    t.integer :course_id, null: false
312
  end
313

314
  create_table :essays, force: true do |t|
315 316 317
    t.string :name
    t.string :writer_id
    t.string :writer_type
318 319
    t.string :category_id
    t.string :author_id
320 321
  end

322 323
  create_table :events, force: true do |t|
    t.string :title, limit: 5
324 325
  end

326
  create_table :eyes, force: true do |t|
327 328
  end

329
  create_table :funny_jokes, force: true do |t|
330
    t.string :name
331 332
  end

333
  create_table :cold_jokes, force: true do |t|
S
💣  
Sean Griffin 已提交
334
    t.string :cold_name
335 336
  end

337
  create_table :friendships, force: true do |t|
338
    t.integer :friend_id
339
    t.integer :follower_id
340 341
  end

342 343
  create_table :goofy_string_id, force: true, id: false do |t|
    t.string :id, null: false
344 345 346
    t.string :info
  end

347
  create_table :having, force: true do |t|
348 349 350
    t.string :where
  end

351
  create_table :guids, force: true do |t|
352
    t.column :key, :string
353 354
  end

Y
Yves Senn 已提交
355
  create_table :guitars, force: true do |t|
356 357 358
    t.string :color
  end

359 360 361
  create_table :inept_wizards, force: true do |t|
    t.column :name, :string, null: false
    t.column :city, :string, null: false
362
    t.column :type, :string
363 364
  end

365
  create_table :integer_limits, force: true do |t|
366 367
    t.integer :"c_int_without_limit"
    (1..8).each do |i|
368
      t.integer :"c_int_#{i}", limit: i
369 370 371
    end
  end

372
  create_table :invoices, force: true do |t|
373
    t.integer :balance
374 375 376 377 378
    if subsecond_precision_supported?
      t.datetime :updated_at, precision: 6
    else
      t.datetime :updated_at
    end
379 380
  end

381
  create_table :iris, force: true do |t|
382 383 384 385
    t.references :eye
    t.string     :color
  end

386
  create_table :items, force: true do |t|
387 388
    t.column :name, :string
  end
389

390
  create_table :jobs, force: true do |t|
391 392 393
    t.integer :ideal_reference_id
  end

394 395 396 397 398
  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 已提交
399
  create_table :keyboards, force: true, id: false do |t|
400 401
    t.primary_key :key_number
    t.string      :name
402 403
  end

404
  create_table :legacy_things, force: true do |t|
405
    t.integer :tps_report_number
406
    t.integer :version, null: false, default: 0
407 408
  end

409
  create_table :lessons, force: true do |t|
410 411 412
    t.string :name
  end

413
  create_table :lessons_students, id: false, force: true do |t|
414 415 416 417
    t.references :lesson
    t.references :student
  end

418 419 420 421 422 423 424 425
  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

426
  create_table :lint_models, force: true
427

428
  create_table :line_items, force: true do |t|
429 430 431 432
    t.integer :invoice_id
    t.integer :amount
  end

433 434 435 436 437
  create_table :lions, force: true do |t|
    t.integer :gender
    t.boolean :is_vegetarian, default: false
  end

438
  create_table :lock_without_defaults, force: true do |t|
439 440
    t.column :lock_version, :integer
  end
441

442
  create_table :lock_without_defaults_cust, force: true do |t|
443
    t.column :custom_lock_version, :integer
444
  end
445

446 447 448
  create_table :magazines, force: true do |t|
  end

449
  create_table :mateys, id: false, force: true do |t|
450 451 452
    t.column :pirate_id, :integer
    t.column :target_id, :integer
    t.column :weight, :integer
453
  end
J
Jeremy Kemper 已提交
454

455
  create_table :members, force: true do |t|
456
    t.string :name
457
    t.integer :member_type_id
J
Jeremy Kemper 已提交
458 459
  end

460
  create_table :member_details, force: true do |t|
461 462 463 464 465
    t.integer :member_id
    t.integer :organization_id
    t.string :extra_data
  end

466
  create_table :member_friends, force: true, id: false do |t|
467 468 469 470
    t.integer :member_id
    t.integer :friend_id
  end

471
  create_table :memberships, force: true do |t|
472 473
    t.datetime :joined_on
    t.integer :club_id, :member_id
474
    t.boolean :favourite, default: false
475
    t.string :type
J
Jeremy Kemper 已提交
476
  end
477

478
  create_table :member_types, force: true do |t|
479 480 481
    t.string :name
  end

482 483 484 485
  create_table :mentors, force: true do |t|
    t.string :name
  end

486
  create_table :minivans, force: true, id: false do |t|
487 488 489
    t.string :minivan_id
    t.string :name
    t.string :speedometer_id
490
    t.string :color
491
  end
492

493
  create_table :minimalistics, force: true do |t|
494
  end
J
Jeremy Kemper 已提交
495

496
  create_table :mixed_case_monkeys, force: true, id: false do |t|
497 498
    t.primary_key :monkeyID
    t.integer     :fleaCount
499
  end
J
Jeremy Kemper 已提交
500

501
  create_table :mixins, force: true do |t|
502 503 504 505 506 507 508 509
    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
510
  end
511

512
  create_table :movies, force: true, id: false do |t|
513 514
    t.primary_key :movieid
    t.string      :name
515
  end
M
Michael Ryan 已提交
516 517 518 519

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

521 522 523 524 525 526
  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
527
    t.float   :temperature
528
    # Oracle/SQLServer supports precision up to 38
529
    if current_adapter?(:OracleAdapter, :SQLServerAdapter)
530
      t.decimal :atoms_in_universe, precision: 38, scale: 0
R
Ray Zane 已提交
531 532
    elsif current_adapter?(:FbAdapter)
      t.decimal :atoms_in_universe, precision: 18, scale: 0
533
    else
534
      t.decimal :atoms_in_universe, precision: 55, scale: 0
535
    end
536
  end
537

538
  create_table :orders, force: true do |t|
539 540 541
    t.string  :name
    t.integer :billing_customer_id
    t.integer :shipping_customer_id
542
  end
543

544
  create_table :organizations, force: true do |t|
545 546 547
    t.string :name
  end

548
  create_table :owners, primary_key: :owner_id, force: true do |t|
549
    t.string :name
550 551 552 553 554
    if subsecond_precision_supported?
      t.column :updated_at, :datetime, precision: 6
    else
      t.column :updated_at, :datetime
    end
555
    t.column :happy_at,   :datetime
556
    t.string :essay_id
557 558
  end

559
  create_table :paint_colors, force: true do |t|
560
    t.integer :non_poly_one_id
561 562
  end

563
  create_table :paint_textures, force: true do |t|
564
    t.integer :non_poly_two_id
565
  end
566

567
  create_table :parrots, force: true do |t|
568
    t.column :name, :string
569
    t.column :color, :string
570 571
    t.column :parrot_sti_class, :string
    t.column :killer_id, :integer
572 573 574 575 576 577 578 579 580 581 582
    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
583 584
  end

585
  create_table :parrots_pirates, id: false, force: true do |t|
586 587 588 589
    t.column :parrot_id, :integer
    t.column :pirate_id, :integer
  end

590
  create_table :parrots_treasures, id: false, force: true do |t|
591 592 593
    t.column :parrot_id, :integer
    t.column :treasure_id, :integer
  end
594

595 596
  create_table :people, force: true do |t|
    t.string     :first_name, null: false
597
    t.references :primary_contact
598
    t.string     :gender, limit: 1
599
    t.references :number1_fan
600
    t.integer    :lock_version, null: false, default: 0
601
    t.string     :comments
602 603
    t.integer    :followers_count, default: 0
    t.integer    :friends_too_count, default: 0
604 605
    t.references :best_friend
    t.references :best_friend_of
606
    t.integer    :insures, null: false, default: 0
607
    t.timestamp :born_at
608
    t.timestamps null: false
609
  end
J
Jon Leighton 已提交
610

611
  create_table :peoples_treasures, id: false, force: true do |t|
612 613 614
    t.column :rich_person_id, :integer
    t.column :treasure_id, :integer
  end
615

616 617 618 619 620 621
  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

622
  create_table :pets, primary_key: :pet_id, force: true do |t|
623
    t.string :name
624
    t.integer :owner_id, :integer
625 626 627 628 629
    if subsecond_precision_supported?
      t.timestamps null: false, precision: 6
    else
      t.timestamps null: false
    end
630
  end
631

632 633 634 635 636 637
  create_table :pets_treasures, force: true do |t|
    t.column :treasure_id, :integer
    t.column :pet_id, :integer
    t.column :rainbow_color, :string
  end

638
  create_table :pirates, force: true do |t|
639 640
    t.column :catchphrase, :string
    t.column :parrot_id, :integer
641
    t.integer :non_validated_parrot_id
642 643 644 645 646 647 648
    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
649
  end
650

651
  create_table :posts, force: true do |t|
652
    t.integer :author_id
653
    t.string  :title, null: false
654 655 656
    # 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)
657
      t.string  :body, null: false, limit: 4000
658
    else
659
      t.text    :body, null: false
660
    end
661
    t.string  :type
662 663 664 665 666 667
    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
668
  end
669

670 671 672 673 674
  create_table :serialized_posts, force: true do |t|
    t.integer :author_id
    t.string :title, null: false
  end

675 676 677 678 679
  create_table :images, force: true do |t|
    t.integer :imageable_identifier
    t.string :imageable_class
  end

680
  create_table :price_estimates, force: true do |t|
681 682 683 684
    t.string :estimate_of_type
    t.integer :estimate_of_id
    t.integer :price
  end
685

686
  create_table :products, force: true do |t|
687
    t.references :collection
688
    t.references :type
689 690 691
    t.string     :name
  end

692 693 694 695
  create_table :product_types, force: true do |t|
    t.string :name
  end

696
  create_table :projects, force: true do |t|
697 698
    t.string :name
    t.string :type
699
    t.integer :firm_id
700
    t.integer :mentor_id
701 702
  end

V
Vipul A M 已提交
703 704 705 706 707 708 709 710 711 712 713
  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|
714 715 716 717
    t.string  :some_attribute
    t.integer :another_attribute
  end

718
  create_table :ratings, force: true do |t|
719 720 721 722
    t.integer :comment_id
    t.integer :value
  end

723 724 725 726
  create_table :readers, force: true do |t|
    t.integer :post_id, null: false
    t.integer :person_id, null: false
    t.boolean :skimmer, default: false
727
    t.integer :first_post_id
728 729
  end

730
  create_table :references, force: true do |t|
731 732 733
    t.integer :person_id
    t.integer :job_id
    t.boolean :favourite
734
    t.integer :lock_version, default: 0
735 736
  end

737
  create_table :shape_expressions, force: true do |t|
738 739 740 741 742
    t.string  :paint_type
    t.integer :paint_id
    t.string  :shape_type
    t.integer :shape_id
  end
743

744
  create_table :ships, force: true do |t|
745
    t.string :name
746
    t.integer :pirate_id
747
    t.belongs_to :developer
748
    t.integer :update_only_pirate_id
749 750
    # Conventionally named column for counter_cache
    t.integer :treasures_count, default: 0
751 752 753 754
    t.datetime :created_at
    t.datetime :created_on
    t.datetime :updated_at
    t.datetime :updated_on
755
  end
756

757
  create_table :ship_parts, force: true do |t|
758 759
    t.string :name
    t.integer :ship_id
760 761 762 763 764
    if subsecond_precision_supported?
      t.datetime :updated_at, precision: 6
    else
      t.datetime :updated_at
    end
765
  end
766

767 768 769 770
  create_table :prisoners, force: true do |t|
    t.belongs_to :ship
  end

771 772 773 774 775
  create_table :shop_accounts, force: true do |t|
    t.references :customer
    t.references :customer_carrier
  end

776
  create_table :speedometers, force: true, id: false do |t|
777 778 779 780
    t.string :speedometer_id
    t.string :name
    t.string :dashboard_id
  end
781

782
  create_table :sponsors, force: true do |t|
783 784
    t.integer :club_id
    t.integer :sponsorable_id
785
    t.string :sponsorable_type
786
  end
787

788
  create_table :string_key_objects, id: false, primary_key: :id, force: true do |t|
789 790
    t.string     :id
    t.string     :name
791
    t.integer    :lock_version, null: false, default: 0
792 793
  end

794 795
  create_table :subscribers, force: true, id: false do |t|
    t.string :nick, null: false
796
    t.string :name
797
    t.column :books_count, :integer, null: false, default: 0
798
    t.index :nick, unique: true
799 800
  end

801
  create_table :subscriptions, force: true do |t|
802 803 804 805
    t.string :subscriber_id
    t.integer :book_id
  end

806
  create_table :tags, force: true do |t|
807
    t.column :name, :string
808
    t.column :taggings_count, :integer, default: 0
809 810
  end

811
  create_table :taggings, force: true do |t|
812 813 814 815
    t.column :tag_id, :integer
    t.column :super_tag_id, :integer
    t.column :taggable_type, :string
    t.column :taggable_id, :integer
816
    t.string :comment
817 818
  end

819
  create_table :tasks, force: true do |t|
820 821
    t.datetime :starting
    t.datetime :ending
822 823
  end

824
  create_table :topics, force: true do |t|
825
    t.string   :title, limit: 250
826 827
    t.string   :author_name
    t.string   :author_email_address
828
    if subsecond_precision_supported?
829
      t.datetime :written_on, precision: 6
A
Arthur Neves 已提交
830 831 832
    else
      t.datetime :written_on
    end
833 834
    t.time     :bonus_time
    t.date     :last_read
835 836 837
    # 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)
838 839
      t.string   :content, limit: 4000
      t.string   :important, limit: 4000
840 841
    else
      t.text     :content
A
Alvaro Bautista 已提交
842
      t.text     :important
843
    end
844 845 846
    t.boolean  :approved, default: true
    t.integer  :replies_count, default: 0
    t.integer  :unique_replies_count, default: 0
847
    t.integer  :parent_id
848
    t.string   :parent_title
849
    t.string   :type
850
    t.string   :group
851 852 853 854 855
    if subsecond_precision_supported?
      t.timestamps null: true, precision: 6
    else
      t.timestamps null: true
    end
856 857
  end

858
  create_table :toys, primary_key: :toy_id, force: true do |t|
859 860
    t.string :name
    t.integer :pet_id, :integer
861
    t.timestamps null: false
862 863
  end

864
  create_table :traffic_lights, force: true do |t|
865 866
    t.string   :location
    t.string   :state
867
    t.text     :long_state, null: false
868 869 870 871
    t.datetime :created_at
    t.datetime :updated_at
  end

872
  create_table :treasures, force: true do |t|
873
    t.column :name, :string
874
    t.column :type, :string
875 876
    t.column :looter_id, :integer
    t.column :looter_type, :string
877
    t.belongs_to :ship
878 879
  end

880 881 882 883 884
  create_table :tuning_pegs, force: true do |t|
    t.integer :guitar_id
    t.float :pitch
  end

885
  create_table :tyres, force: true do |t|
886 887 888
    t.integer :car_id
  end

889
  create_table :variants, force: true do |t|
890 891 892 893
    t.references :product
    t.string     :name
  end

894
  create_table :vertices, force: true do |t|
895 896 897
    t.column :label, :string
  end

898
  create_table "warehouse-things", force: true do |t|
899 900 901 902
    t.integer :value
  end

  [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
903
    create_table(t, force: true) {}
904 905
  end

906
  # NOTE - the following 4 tables are used by models that have :inverse_of options on the associations
907
  create_table :men, force: true do |t|
908 909 910
    t.string  :name
  end

911
  create_table :faces, force: true do |t|
912 913
    t.string  :description
    t.integer :man_id
914
    t.integer :polymorphic_man_id
915
    t.string  :polymorphic_man_type
916 917
    t.integer :poly_man_without_inverse_id
    t.string  :poly_man_without_inverse_type
918 919
    t.integer :horrible_polymorphic_man_id
    t.string  :horrible_polymorphic_man_type
920 921
  end

922
  create_table :interests, force: true do |t|
923 924
    t.string :topic
    t.integer :man_id
925 926
    t.integer :polymorphic_man_id
    t.string :polymorphic_man_type
927 928 929
    t.integer :zine_id
  end

930 931
  create_table :wheels, force: true do |t|
    t.references :wheelable, polymorphic: true
932 933
  end

934
  create_table :zines, force: true do |t|
935 936 937
    t.string :title
  end

938
  create_table :countries, force: true, id: false, primary_key: "country_id" do |t|
939 940 941
    t.string :country_id
    t.string :name
  end
942
  create_table :treaties, force: true, id: false, primary_key: "treaty_id" do |t|
943 944 945
    t.string :treaty_id
    t.string :name
  end
946
  create_table :countries_treaties, force: true, primary_key: [:country_id, :treaty_id] do |t|
947 948
    t.string :country_id, null: false
    t.string :treaty_id, null: false
949 950
  end

951
  create_table :liquid, force: true do |t|
952 953
    t.string :name
  end
954
  create_table :molecules, force: true do |t|
955 956 957
    t.integer :liquid_id
    t.string :name
  end
958
  create_table :electrons, force: true do |t|
959 960 961
    t.integer :molecule_id
    t.string :name
  end
962
  create_table :weirds, force: true do |t|
963 964 965
    t.string "a$b"
    t.string "なまえ"
    t.string "from"
966
  end
967

968 969 970 971 972 973 974 975 976 977 978
  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

979 980 981 982 983 984 985 986 987 988 989 990 991
  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
992 993
    t.string :employable_list_type
    t.integer :employable_list_id
994
  end
995 996 997 998
  create_table :recipes, force: true do |t|
    t.integer :chef_id
    t.integer :hotel_id
  end
999

1000 1001
  create_table :records, force: true do |t|
  end
1002

1003
  if supports_foreign_keys?
1004
    # fk_test_has_fk should be before fk_test_has_pk
1005 1006
    create_table :fk_test_has_fk, force: true do |t|
      t.integer :fk_id, null: false
1007 1008
    end

Y
Yves Senn 已提交
1009
    create_table :fk_test_has_pk, force: true, primary_key: "pk_id" do |t|
1010 1011
    end

Y
Yves Senn 已提交
1012
    add_foreign_key :fk_test_has_fk, :fk_test_has_pk, column: "fk_id", name: "fk_name", primary_key: "pk_id"
1013
  end
1014 1015 1016 1017 1018

  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
1019
    t.string :string_with_default, default: "the original default"
1020
  end
1021 1022 1023 1024 1025

  create_table :users, force: true do |t|
    t.string :token
    t.string :auth_token
  end
1026 1027 1028 1029

  create_table :test_with_keyword_column_name, force: true do |t|
    t.string :desc
  end
1030
end
1031

1032 1033
Course.connection.create_table :courses, force: true do |t|
  t.column :name, :string, null: false
R
Rick Martinez 已提交
1034 1035 1036
  t.column :college_id, :integer
end

1037 1038
College.connection.create_table :colleges, force: true do |t|
  t.column :name, :string, null: false
1039
end
1040 1041 1042 1043 1044 1045 1046 1047 1048

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