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
    t.column :title, :string
440 441
    t.column :lock_version, :integer
  end
442

443
  create_table :lock_without_defaults_cust, force: true do |t|
444
    t.column :title, :string
445
    t.column :custom_lock_version, :integer
446
  end
447

448 449 450
  create_table :magazines, force: true do |t|
  end

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

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

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

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

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

480
  create_table :member_types, force: true do |t|
481 482 483
    t.string :name
  end

484 485 486 487
  create_table :mentors, force: true do |t|
    t.string :name
  end

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

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

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

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

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

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

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

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

546
  create_table :organizations, force: true do |t|
547 548 549
    t.string :name
  end

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

561
  create_table :paint_colors, force: true do |t|
562
    t.integer :non_poly_one_id
563 564
  end

565
  create_table :paint_textures, force: true do |t|
566
    t.integer :non_poly_two_id
567
  end
568

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

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

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

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

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

618 619 620 621 622 623
  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

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

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

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

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

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

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

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

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

694 695 696 697
  create_table :product_types, force: true do |t|
    t.string :name
  end

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

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

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

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

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

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

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

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

769 770 771 772
  create_table :prisoners, force: true do |t|
    t.belongs_to :ship
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

887
  create_table :tyres, force: true do |t|
888 889 890
    t.integer :car_id
  end

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

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

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

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

908
  create_table :men, force: true do |t|
909 910 911
    t.string  :name
  end

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

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

931
  create_table :zines, force: true do |t|
932 933 934
    t.string :title
  end

935 936 937 938
  create_table :wheels, force: true do |t|
    t.references :wheelable, polymorphic: true
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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