| | 2 | |
|---|
| | 3 | # adapter name is checked because we are under a transition of |
|---|
| | 4 | # moving the sql files under activerecord/test/fixtures/db_definitions |
|---|
| | 5 | # to this file, schema.rb. |
|---|
| | 6 | if adapter_name == "MySQL" |
|---|
| | 7 | |
|---|
| | 8 | # Please keep these create table statements in alphabetical order |
|---|
| | 9 | # unless the ordering matters. In which case, define them below |
|---|
| | 10 | create_table :accounts, :force => true do |t| |
|---|
| | 11 | t.integer :firm_id |
|---|
| | 12 | t.integer :credit_limit |
|---|
| | 13 | end |
|---|
| | 14 | |
|---|
| | 15 | create_table :authors, :force => true do |t| |
|---|
| | 16 | t.string :name, :null => false |
|---|
| | 17 | end |
|---|
| | 18 | |
|---|
| | 19 | create_table :auto_id_tests, :force => true, :id => false do |t| |
|---|
| | 20 | t.primary_key :auto_id |
|---|
| | 21 | t.integer :value |
|---|
| | 22 | end |
|---|
| | 23 | |
|---|
| | 24 | create_table :binaries, :force => true do |t| |
|---|
| | 25 | t.binary :data |
|---|
| | 26 | end |
|---|
| | 27 | |
|---|
| | 28 | create_table :booleantests, :force => true do |t| |
|---|
| | 29 | t.integer :value |
|---|
| | 30 | end |
|---|
| | 31 | |
|---|
| | 32 | create_table :categories, :force => true do |t| |
|---|
| | 33 | t.string :name, :null => false |
|---|
| | 34 | t.string :type |
|---|
| | 35 | end |
|---|
| | 36 | |
|---|
| | 37 | create_table :categories_posts, :force => true, :id => false do |t| |
|---|
| | 38 | t.integer :category_id, :null => false |
|---|
| | 39 | t.integer :post_id, :null => false |
|---|
| | 40 | end |
|---|
| | 41 | |
|---|
| | 42 | create_table :colnametests, :force => true do |t| |
|---|
| | 43 | t.integer :references, :null => false |
|---|
| | 44 | end |
|---|
| | 45 | |
|---|
| | 46 | create_table :comments, :force => true do |t| |
|---|
| | 47 | t.integer :post_id, :null => false |
|---|
| | 48 | t.text :body, :null => false |
|---|
| | 49 | t.string :type |
|---|
| | 50 | end |
|---|
| | 51 | |
|---|
| | 52 | create_table :companies, :force => true do |t| |
|---|
| | 53 | t.string :type |
|---|
| | 54 | t.string :ruby_type |
|---|
| | 55 | t.integer :firm_id |
|---|
| | 56 | t.string :name |
|---|
| | 57 | t.integer :client_of |
|---|
| | 58 | t.integer :rating, :default => 1 |
|---|
| | 59 | end |
|---|
| | 60 | |
|---|
| | 61 | create_table :computers, :force => true do |t| |
|---|
| | 62 | t.integer :developer, :null => false |
|---|
| | 63 | t.integer :extendedWarranty, :null => false |
|---|
| | 64 | end |
|---|
| | 65 | |
|---|
| | 66 | |
|---|
| | 67 | create_table :customers, :force => true do |t| |
|---|
| | 68 | t.string :name |
|---|
| | 69 | t.integer :balance, :default => 0 |
|---|
| | 70 | t.string :address_street |
|---|
| | 71 | t.string :address_city |
|---|
| | 72 | t.string :address_country |
|---|
| | 73 | t.string :gps_location |
|---|
| | 74 | end |
|---|
| | 75 | |
|---|
| | 76 | create_table :developers, :force => true do |t| |
|---|
| | 77 | t.string :name |
|---|
| | 78 | t.integer :salary, :default => 70000 |
|---|
| | 79 | t.datetime :created_at |
|---|
| | 80 | t.datetime :updated_at |
|---|
| | 81 | end |
|---|
| | 82 | |
|---|
| | 83 | create_table :developers_projects, :force => true, :id => false do |t| |
|---|
| | 84 | t.integer :developer_id, :null => false |
|---|
| | 85 | t.integer :project_id, :null => false |
|---|
| | 86 | t.date :joined_on |
|---|
| | 87 | t.integer :access_level, :default => 1 |
|---|
| | 88 | end |
|---|
| | 89 | |
|---|
| | 90 | create_table :entrants, :force => true do |t| |
|---|
| | 91 | t.string :name, :null => false |
|---|
| | 92 | t.integer :course_id, :null => false |
|---|
| | 93 | end |
|---|
| | 94 | |
|---|
| | 95 | create_table :funny_jokes, :force => true do |t| |
|---|
| | 96 | t.string :name |
|---|
| | 97 | end |
|---|
| | 98 | |
|---|
| | 99 | create_table :keyboards, :force => true, :id => false do |t| |
|---|
| | 100 | t.primary_key :key_number |
|---|
| | 101 | t.string :name |
|---|
| | 102 | end |
|---|
| | 103 | |
|---|
| | 104 | create_table :legacy_things, :force => true do |t| |
|---|
| | 105 | t.integer :tps_report_number |
|---|
| | 106 | t.integer :version, :null => false, :default => 0 |
|---|
| | 107 | end |
|---|
| | 108 | |
|---|
| | 109 | create_table :minimalistics, :force => true do |t| |
|---|
| | 110 | end |
|---|
| | 111 | |
|---|
| | 112 | create_table :mixed_case_monkeys, :force => true, :id => false do |t| |
|---|
| | 113 | t.primary_key :monkeyID |
|---|
| | 114 | t.integer :fleaCount |
|---|
| | 115 | end |
|---|
| | 116 | |
|---|
| | 117 | create_table :mixins, :force => true do |t| |
|---|
| | 118 | t.integer :parent_id |
|---|
| | 119 | t.integer :pos |
|---|
| | 120 | t.datetime :created_at |
|---|
| | 121 | t.datetime :updated_at |
|---|
| | 122 | t.integer :lft |
|---|
| | 123 | t.integer :rgt |
|---|
| | 124 | t.integer :root_id |
|---|
| | 125 | t.string :type |
|---|
| | 126 | end |
|---|
| | 127 | |
|---|
| | 128 | create_table :movies, :force => true, :id => false do |t| |
|---|
| | 129 | t.primary_key :movieid |
|---|
| | 130 | t.string :name |
|---|
| | 131 | end |
|---|
| | 132 | |
|---|
| | 133 | create_table :numeric_data, :force => true do |t| |
|---|
| | 134 | t.decimal :bank_balance, :precision => 10, :scale => 2 |
|---|
| | 135 | t.decimal :big_bank_balance, :precision => 15, :scale => 2 |
|---|
| | 136 | t.decimal :world_population, :precision => 10, :scale => 0 |
|---|
| | 137 | t.decimal :my_house_population, :precision => 2, :scale => 0 |
|---|
| | 138 | t.decimal :decimal_number_with_default, :precision => 3, :scale => 2, :default => 2.78 |
|---|
| | 139 | end |
|---|
| | 140 | |
|---|
| | 141 | create_table :orders, :force => true do |t| |
|---|
| | 142 | t.string :name |
|---|
| | 143 | t.integer :billing_customer_id |
|---|
| | 144 | t.integer :shipping_customer_id |
|---|
| | 145 | end |
|---|
| | 146 | |
|---|
| | 147 | create_table :people, :force => true do |t| |
|---|
| | 148 | t.string :first_name, :null => false |
|---|
| | 149 | t.integer :lock_version, :null => false, :default => 0 |
|---|
| | 150 | end |
|---|
| | 151 | |
|---|
| | 152 | create_table :posts, :force => true do |t| |
|---|
| | 153 | t.integer :author_id |
|---|
| | 154 | t.string :title, :null => false |
|---|
| | 155 | t.text :body, :null => false |
|---|
| | 156 | t.string :type |
|---|
| | 157 | end |
|---|
| | 158 | |
|---|
| | 159 | create_table :projects, :force => true do |t| |
|---|
| | 160 | t.string :name |
|---|
| | 161 | t.string :type |
|---|
| | 162 | end |
|---|
| | 163 | |
|---|
| | 164 | create_table :readers, :force => true do |t| |
|---|
| | 165 | t.integer :post_id, :null => false |
|---|
| | 166 | t.integer :person_id, :null => false |
|---|
| | 167 | end |
|---|
| | 168 | |
|---|
| | 169 | create_table :subscribers, :force => true, :id => false do |t| |
|---|
| | 170 | t.string :nick, :null => false |
|---|
| | 171 | t.string :name |
|---|
| | 172 | end |
|---|
| | 173 | add_index :subscribers, :nick, :unique => true |
|---|
| | 174 | |
|---|
| | 175 | create_table :tasks, :force => true do |t| |
|---|
| | 176 | t.datetime :starting |
|---|
| | 177 | t.datetime :ending |
|---|
| | 178 | end |
|---|
| | 179 | |
|---|
| | 180 | create_table :topics, :force => true do |t| |
|---|
| | 181 | t.string :title |
|---|
| | 182 | t.string :author_name |
|---|
| | 183 | t.string :author_email_address |
|---|
| | 184 | t.datetime :written_on |
|---|
| | 185 | t.time :bonus_time |
|---|
| | 186 | t.date :last_read |
|---|
| | 187 | t.text :content |
|---|
| | 188 | t.boolean :approved, :default => true |
|---|
| | 189 | t.integer :replies_count, :default => 0 |
|---|
| | 190 | t.integer :parent_id |
|---|
| | 191 | t.string :type |
|---|
| | 192 | end |
|---|
| | 193 | |
|---|
| | 194 | |
|---|
| | 195 | |
|---|
| | 196 | ### These tables are created last as the order is significant |
|---|
| | 197 | |
|---|
| | 198 | # fk_test_has_fk should be before fk_test_has_pk |
|---|
| | 199 | create_table :fk_test_has_fk, :force => true do |t| |
|---|
| | 200 | t.integer :fk_id, :null => false |
|---|
| | 201 | end |
|---|
| | 202 | |
|---|
| | 203 | create_table :fk_test_has_pk, :force => true do |t| |
|---|
| | 204 | end |
|---|
| | 205 | |
|---|
| | 206 | execute 'alter table fk_test_has_fk |
|---|
| | 207 | add FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`)' |
|---|
| | 208 | |
|---|
| | 209 | |
|---|
| | 210 | end |
|---|