schema.rb 27.5 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.references :author_address
    t.references :author_address_extra
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.references :author
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 131
  create_table :old_cars, id: :integer, force: true do |t|
  end

132 133
  create_table :carriers, force: true

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

140 141 142
  create_table :categories_posts, force: true, id: false do |t|
    t.integer :category_id, null: false
    t.integer :post_id, null: false
143
  end
144

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

153
  create_table :citations, force: true do |t|
154 155 156
    t.column :book1_id, :integer
    t.column :book2_id, :integer
  end
157

158
  create_table :clubs, force: true do |t|
159
    t.string :name
160
    t.integer :category_id
161
  end
J
Jeremy Kemper 已提交
162

163
  create_table :collections, force: true do |t|
164 165 166
    t.string :name
  end

167 168
  create_table :colnametests, force: true do |t|
    t.integer :references, null: false
169
  end
J
Jeremy Kemper 已提交
170

171 172 173 174
  create_table :columns, force: true do |t|
    t.references :record
  end

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

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

209 210 211 212 213 214 215 216
  create_table :content, force: true do |t|
    t.string :title
  end

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

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

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

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

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

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

248 249 250 251 252
  create_table :customer_carriers, force: true do |t|
    t.references :customer
    t.references :carrier
  end

253
  create_table :dashboards, force: true, id: false do |t|
254 255 256
    t.string :dashboard_id
    t.string :name
  end
257

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

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

284 285 286 287
  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
288 289
  end

290
  create_table :dogs, force: true do |t|
291 292
    t.integer :trainer_id
    t.integer :breeder_id
293
    t.integer :dog_lover_id
294
    t.string  :alias
295 296
  end

297 298 299 300 301
  create_table :doubloons, force: true do |t|
    t.integer :pirate_id
    t.integer :weight
  end

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

308
  create_table :engines, force: true do |t|
309
    t.references :car, index: false
310
  end
311

312 313 314
  create_table :entrants, force: true do |t|
    t.string  :name, null: false
    t.integer :course_id, null: false
315
  end
316

317
  create_table :essays, force: true do |t|
318 319 320
    t.string :name
    t.string :writer_id
    t.string :writer_type
321 322
    t.string :category_id
    t.string :author_id
323 324
  end

325 326
  create_table :events, force: true do |t|
    t.string :title, limit: 5
327 328
  end

329
  create_table :eyes, force: true do |t|
330 331
  end

332 333 334 335 336 337 338 339 340
  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

341
  create_table :funny_jokes, force: true do |t|
342
    t.string :name
343 344
  end

345
  create_table :cold_jokes, force: true do |t|
S
💣  
Sean Griffin 已提交
346
    t.string :cold_name
347 348
  end

349
  create_table :friendships, force: true do |t|
350
    t.integer :friend_id
351
    t.integer :follower_id
352 353
  end

354 355
  create_table :goofy_string_id, force: true, id: false do |t|
    t.string :id, null: false
356 357 358
    t.string :info
  end

359
  create_table :having, force: true do |t|
360 361 362
    t.string :where
  end

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

Y
Yves Senn 已提交
367
  create_table :guitars, force: true do |t|
368 369 370
    t.string :color
  end

371 372 373
  create_table :inept_wizards, force: true do |t|
    t.column :name, :string, null: false
    t.column :city, :string, null: false
374
    t.column :type, :string
375 376
  end

377
  create_table :integer_limits, force: true do |t|
378 379
    t.integer :"c_int_without_limit"
    (1..8).each do |i|
380
      t.integer :"c_int_#{i}", limit: i
381 382 383
    end
  end

384
  create_table :invoices, force: true do |t|
385
    t.integer :balance
386 387 388 389 390
    if subsecond_precision_supported?
      t.datetime :updated_at, precision: 6
    else
      t.datetime :updated_at
    end
391 392
  end

393
  create_table :iris, force: true do |t|
394 395 396 397
    t.references :eye
    t.string     :color
  end

398
  create_table :items, force: true do |t|
399 400
    t.column :name, :string
  end
401

402
  create_table :jobs, force: true do |t|
403 404 405
    t.integer :ideal_reference_id
  end

406 407 408 409 410
  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 已提交
411
  create_table :keyboards, force: true, id: false do |t|
412 413
    t.primary_key :key_number
    t.string      :name
414 415
  end

416 417 418
  create_table :kitchens, force: true do |t|
  end

419
  create_table :legacy_things, force: true do |t|
420
    t.integer :tps_report_number
421
    t.integer :version, null: false, default: 0
422 423
  end

424
  create_table :lessons, force: true do |t|
425 426 427
    t.string :name
  end

428
  create_table :lessons_students, id: false, force: true do |t|
429 430 431 432
    t.references :lesson
    t.references :student
  end

433 434 435 436 437 438 439 440
  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

441
  create_table :lint_models, force: true
442

443
  create_table :line_items, force: true do |t|
444 445 446 447
    t.integer :invoice_id
    t.integer :amount
  end

448 449 450 451 452
  create_table :lions, force: true do |t|
    t.integer :gender
    t.boolean :is_vegetarian, default: false
  end

453
  create_table :lock_without_defaults, force: true do |t|
454
    t.column :title, :string
455 456
    t.column :lock_version, :integer
  end
457

458
  create_table :lock_without_defaults_cust, force: true do |t|
459
    t.column :title, :string
460
    t.column :custom_lock_version, :integer
461
  end
462

463 464 465
  create_table :magazines, force: true do |t|
  end

466
  create_table :mateys, id: false, force: true do |t|
467 468 469
    t.column :pirate_id, :integer
    t.column :target_id, :integer
    t.column :weight, :integer
470
  end
J
Jeremy Kemper 已提交
471

472
  create_table :members, force: true do |t|
473
    t.string :name
474
    t.integer :member_type_id
J
Jeremy Kemper 已提交
475 476
  end

477
  create_table :member_details, force: true do |t|
478 479 480 481 482
    t.integer :member_id
    t.integer :organization_id
    t.string :extra_data
  end

483
  create_table :member_friends, force: true, id: false do |t|
484 485 486 487
    t.integer :member_id
    t.integer :friend_id
  end

488
  create_table :memberships, force: true do |t|
489 490
    t.datetime :joined_on
    t.integer :club_id, :member_id
491
    t.boolean :favourite, default: false
492
    t.string :type
J
Jeremy Kemper 已提交
493
  end
494

495
  create_table :member_types, force: true do |t|
496 497 498
    t.string :name
  end

499 500 501 502
  create_table :mentors, force: true do |t|
    t.string :name
  end

503
  create_table :minivans, force: true, id: false do |t|
504 505 506
    t.string :minivan_id
    t.string :name
    t.string :speedometer_id
507
    t.string :color
508
  end
509

510
  create_table :minimalistics, force: true do |t|
511
  end
J
Jeremy Kemper 已提交
512

513
  create_table :mixed_case_monkeys, force: true, id: false do |t|
514 515
    t.primary_key :monkeyID
    t.integer     :fleaCount
516
  end
J
Jeremy Kemper 已提交
517

518
  create_table :mixins, force: true do |t|
519 520 521 522 523 524 525 526
    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
527
  end
528

529
  create_table :movies, force: true, id: false do |t|
530 531
    t.primary_key :movieid
    t.string      :name
532
  end
M
Michael Ryan 已提交
533 534 535 536

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

538 539 540 541 542 543
  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
544
    t.float   :temperature
545
    # Oracle/SQLServer supports precision up to 38
546
    if current_adapter?(:OracleAdapter, :SQLServerAdapter)
547
      t.decimal :atoms_in_universe, precision: 38, scale: 0
R
Ray Zane 已提交
548 549
    elsif current_adapter?(:FbAdapter)
      t.decimal :atoms_in_universe, precision: 18, scale: 0
550
    else
551
      t.decimal :atoms_in_universe, precision: 55, scale: 0
552
    end
553
  end
554

555
  create_table :orders, force: true do |t|
556 557 558
    t.string  :name
    t.integer :billing_customer_id
    t.integer :shipping_customer_id
559
  end
560

561
  create_table :organizations, force: true do |t|
562 563 564
    t.string :name
  end

565
  create_table :owners, primary_key: :owner_id, force: true do |t|
566
    t.string :name
567 568 569 570 571
    if subsecond_precision_supported?
      t.column :updated_at, :datetime, precision: 6
    else
      t.column :updated_at, :datetime
    end
572
    t.column :happy_at,   :datetime
573
    t.string :essay_id
574 575
  end

576
  create_table :paint_colors, force: true do |t|
577
    t.integer :non_poly_one_id
578 579
  end

580
  create_table :paint_textures, force: true do |t|
581
    t.integer :non_poly_two_id
582
  end
583

584
  create_table :parrots, force: true do |t|
585
    t.column :name, :string
586
    t.column :color, :string
587 588
    t.column :parrot_sti_class, :string
    t.column :killer_id, :integer
589
    t.column :updated_count, :integer, default: 0
590 591 592 593 594 595 596 597 598 599 600
    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
601 602
  end

603
  create_table :parrots_pirates, id: false, force: true do |t|
604 605 606 607
    t.column :parrot_id, :integer
    t.column :pirate_id, :integer
  end

608
  create_table :parrots_treasures, id: false, force: true do |t|
609 610 611
    t.column :parrot_id, :integer
    t.column :treasure_id, :integer
  end
612

613 614
  create_table :people, force: true do |t|
    t.string     :first_name, null: false
615
    t.references :primary_contact
616
    t.string     :gender, limit: 1
617
    t.references :number1_fan
618
    t.integer    :lock_version, null: false, default: 0
619
    t.string     :comments
620 621
    t.integer    :followers_count, default: 0
    t.integer    :friends_too_count, default: 0
622 623
    t.references :best_friend
    t.references :best_friend_of
624
    t.integer    :insures, null: false, default: 0
625
    t.timestamp :born_at
626
    t.timestamps null: false
627
  end
J
Jon Leighton 已提交
628

629
  create_table :peoples_treasures, id: false, force: true do |t|
630 631 632
    t.column :rich_person_id, :integer
    t.column :treasure_id, :integer
  end
633

634 635 636 637 638 639
  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

640
  create_table :pets, primary_key: :pet_id, force: true do |t|
641
    t.string :name
642
    t.integer :owner_id, :integer
643 644 645 646 647
    if subsecond_precision_supported?
      t.timestamps null: false, precision: 6
    else
      t.timestamps null: false
    end
648
  end
649

650 651 652 653 654 655
  create_table :pets_treasures, force: true do |t|
    t.column :treasure_id, :integer
    t.column :pet_id, :integer
    t.column :rainbow_color, :string
  end

656
  create_table :pirates, force: true do |t|
657 658
    t.column :catchphrase, :string
    t.column :parrot_id, :integer
659
    t.integer :non_validated_parrot_id
660 661 662 663 664 665 666
    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
667
  end
668

669
  create_table :posts, force: true do |t|
670 671
    t.references :author
    t.string :title, null: false
672 673 674
    # use VARCHAR2(4000) instead of CLOB datatype as CLOB data type has many limitations in
    # Oracle SELECT WHERE clause which causes many unit test failures
    if current_adapter?(:OracleAdapter)
675
      t.string  :body, null: false, limit: 4000
676
    else
677
      t.text    :body, null: false
678
    end
679
    t.string  :type
680 681 682 683 684 685
    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
686
  end
687

688 689 690 691 692
  create_table :serialized_posts, force: true do |t|
    t.integer :author_id
    t.string :title, null: false
  end

693 694 695 696 697
  create_table :images, force: true do |t|
    t.integer :imageable_identifier
    t.string :imageable_class
  end

698
  create_table :price_estimates, force: true do |t|
699 700 701 702
    t.string :estimate_of_type
    t.integer :estimate_of_id
    t.integer :price
  end
703

704
  create_table :products, force: true do |t|
705
    t.references :collection
706
    t.references :type
707 708 709
    t.string     :name
  end

710 711 712 713
  create_table :product_types, force: true do |t|
    t.string :name
  end

714
  create_table :projects, force: true do |t|
715 716
    t.string :name
    t.string :type
717
    t.integer :firm_id
718
    t.integer :mentor_id
719 720
  end

V
Vipul A M 已提交
721 722 723 724 725 726 727 728 729 730 731
  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|
732 733 734 735
    t.string  :some_attribute
    t.integer :another_attribute
  end

736
  create_table :ratings, force: true do |t|
737 738 739 740
    t.integer :comment_id
    t.integer :value
  end

741 742 743 744
  create_table :readers, force: true do |t|
    t.integer :post_id, null: false
    t.integer :person_id, null: false
    t.boolean :skimmer, default: false
745
    t.integer :first_post_id
746 747
  end

748
  create_table :references, force: true do |t|
749 750 751
    t.integer :person_id
    t.integer :job_id
    t.boolean :favourite
752
    t.integer :lock_version, default: 0
753 754
  end

755
  create_table :shape_expressions, force: true do |t|
756 757 758 759 760
    t.string  :paint_type
    t.integer :paint_id
    t.string  :shape_type
    t.integer :shape_id
  end
761

762
  create_table :ships, force: true do |t|
763
    t.string :name
764
    t.integer :pirate_id
765
    t.belongs_to :developer
766
    t.integer :update_only_pirate_id
767 768
    # Conventionally named column for counter_cache
    t.integer :treasures_count, default: 0
769 770 771 772
    t.datetime :created_at
    t.datetime :created_on
    t.datetime :updated_at
    t.datetime :updated_on
773
  end
774

775
  create_table :ship_parts, force: true do |t|
776 777
    t.string :name
    t.integer :ship_id
778 779 780 781 782
    if subsecond_precision_supported?
      t.datetime :updated_at, precision: 6
    else
      t.datetime :updated_at
    end
783
  end
784

785 786 787 788
  create_table :prisoners, force: true do |t|
    t.belongs_to :ship
  end

789 790 791 792
  create_table :sinks, force: true do |t|
    t.references :kitchen
  end

793 794 795 796 797
  create_table :shop_accounts, force: true do |t|
    t.references :customer
    t.references :customer_carrier
  end

798
  create_table :speedometers, force: true, id: false do |t|
799 800 801 802
    t.string :speedometer_id
    t.string :name
    t.string :dashboard_id
  end
803

804
  create_table :sponsors, force: true do |t|
805 806
    t.integer :club_id
    t.integer :sponsorable_id
807
    t.string :sponsorable_type
808
  end
809

810 811 812 813 814
  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
815 816
  end

817
  create_table :subscribers, force: true do |t|
818
    t.string :nick, null: false
819
    t.string :name
820 821
    t.integer :books_count, null: false, default: 0
    t.integer :update_count, null: false, default: 0
822
    t.index :nick, unique: true
823 824
  end

825
  create_table :subscriptions, force: true do |t|
826 827 828 829
    t.string :subscriber_id
    t.integer :book_id
  end

830
  create_table :tags, force: true do |t|
831
    t.column :name, :string
832
    t.column :taggings_count, :integer, default: 0
833 834
  end

835
  create_table :taggings, force: true do |t|
836 837 838 839
    t.column :tag_id, :integer
    t.column :super_tag_id, :integer
    t.column :taggable_type, :string
    t.column :taggable_id, :integer
840
    t.string :comment
841 842
  end

843
  create_table :tasks, force: true do |t|
844 845
    t.datetime :starting
    t.datetime :ending
846 847
  end

848
  create_table :topics, force: true do |t|
849
    t.string   :title, limit: 250
850 851
    t.string   :author_name
    t.string   :author_email_address
852
    if subsecond_precision_supported?
853
      t.datetime :written_on, precision: 6
A
Arthur Neves 已提交
854 855 856
    else
      t.datetime :written_on
    end
857 858
    t.time     :bonus_time
    t.date     :last_read
859 860 861
    # 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)
862 863
      t.string   :content, limit: 4000
      t.string   :important, limit: 4000
864 865
    else
      t.text     :content
A
Alvaro Bautista 已提交
866
      t.text     :important
867
    end
868 869 870
    t.boolean  :approved, default: true
    t.integer  :replies_count, default: 0
    t.integer  :unique_replies_count, default: 0
871
    t.integer  :parent_id
872
    t.string   :parent_title
873
    t.string   :type
874
    t.string   :group
875 876 877 878 879
    if subsecond_precision_supported?
      t.timestamps null: true, precision: 6
    else
      t.timestamps null: true
    end
880 881
  end

882
  create_table :toys, primary_key: :toy_id, force: true do |t|
883 884
    t.string :name
    t.integer :pet_id, :integer
885
    t.timestamps null: false
886 887
  end

888
  create_table :traffic_lights, force: true do |t|
889 890
    t.string   :location
    t.string   :state
891
    t.text     :long_state, null: false
892 893 894 895
    t.datetime :created_at
    t.datetime :updated_at
  end

896
  create_table :treasures, force: true do |t|
897
    t.column :name, :string
898
    t.column :type, :string
899 900
    t.column :looter_id, :integer
    t.column :looter_type, :string
901
    t.belongs_to :ship
902 903
  end

904 905 906 907 908
  create_table :tuning_pegs, force: true do |t|
    t.integer :guitar_id
    t.float :pitch
  end

909
  create_table :tyres, force: true do |t|
910 911 912
    t.integer :car_id
  end

913
  create_table :variants, force: true do |t|
914 915 916 917
    t.references :product
    t.string     :name
  end

918
  create_table :vertices, force: true do |t|
919 920 921
    t.column :label, :string
  end

922
  create_table "warehouse-things", force: true do |t|
923 924 925 926
    t.integer :value
  end

  [:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
927
    create_table(t, force: true) {}
928 929
  end

930
  create_table :men, force: true do |t|
931 932 933
    t.string  :name
  end

934
  create_table :faces, force: true do |t|
935 936
    t.string  :description
    t.integer :man_id
937
    t.integer :polymorphic_man_id
938
    t.string  :polymorphic_man_type
939 940
    t.integer :poly_man_without_inverse_id
    t.string  :poly_man_without_inverse_type
941 942
    t.integer :horrible_polymorphic_man_id
    t.string  :horrible_polymorphic_man_type
943 944
  end

945
  create_table :interests, force: true do |t|
946 947
    t.string :topic
    t.integer :man_id
948 949
    t.integer :polymorphic_man_id
    t.string :polymorphic_man_type
950 951 952
    t.integer :zine_id
  end

953
  create_table :zines, force: true do |t|
954 955 956
    t.string :title
  end

957 958 959 960
  create_table :wheels, force: true do |t|
    t.references :wheelable, polymorphic: true
  end

961
  create_table :countries, force: true, id: false, primary_key: "country_id" do |t|
962 963 964
    t.string :country_id
    t.string :name
  end
965
  create_table :treaties, force: true, id: false, primary_key: "treaty_id" do |t|
966 967 968
    t.string :treaty_id
    t.string :name
  end
969
  create_table :countries_treaties, force: true, primary_key: [:country_id, :treaty_id] do |t|
970 971
    t.string :country_id, null: false
    t.string :treaty_id, null: false
972 973
  end

974
  create_table :liquid, force: true do |t|
975 976
    t.string :name
  end
977
  create_table :molecules, force: true do |t|
978 979 980
    t.integer :liquid_id
    t.string :name
  end
981
  create_table :electrons, force: true do |t|
982 983 984
    t.integer :molecule_id
    t.string :name
  end
985
  create_table :weirds, force: true do |t|
986 987 988
    t.string "a$b"
    t.string "なまえ"
    t.string "from"
989
  end
990

991 992 993 994 995 996 997 998 999 1000 1001
  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

1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
  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
1015 1016
    t.string :employable_list_type
    t.integer :employable_list_id
1017
  end
1018 1019 1020 1021
  create_table :recipes, force: true do |t|
    t.integer :chef_id
    t.integer :hotel_id
  end
1022

1023 1024
  create_table :records, force: true do |t|
  end
1025

1026 1027
  disable_referential_integrity do
    create_table :fk_test_has_pk, primary_key: "pk_id", force: :cascade do |t|
1028 1029
    end

1030 1031 1032
    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"
1033
    end
1034
  end
1035 1036 1037 1038 1039

  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
1040
    t.string :string_with_default, default: "the original default"
1041
  end
1042 1043 1044 1045 1046

  create_table :users, force: true do |t|
    t.string :token
    t.string :auth_token
  end
1047 1048 1049 1050

  create_table :test_with_keyword_column_name, force: true do |t|
    t.string :desc
  end
1051 1052 1053 1054

  create_table :non_primary_keys, force: true, id: false do |t|
    t.integer :id
  end
1055
end
1056

1057 1058
Course.connection.create_table :courses, force: true do |t|
  t.column :name, :string, null: false
R
Rick Martinez 已提交
1059 1060 1061
  t.column :college_id, :integer
end

1062 1063
College.connection.create_table :colleges, force: true do |t|
  t.column :name, :string, null: false
1064
end
1065 1066 1067 1068 1069 1070 1071 1072 1073

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
1074 1075

OtherDog.connection.create_table :dogs, force: true