activerecord 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

Files changed (311) hide show
  1. data/CHANGELOG +4928 -3
  2. data/README +45 -46
  3. data/RUNNING_UNIT_TESTS +8 -11
  4. data/Rakefile +247 -0
  5. data/install.rb +8 -38
  6. data/lib/active_record/aggregations.rb +64 -49
  7. data/lib/active_record/associations/association_collection.rb +217 -47
  8. data/lib/active_record/associations/association_proxy.rb +159 -0
  9. data/lib/active_record/associations/belongs_to_association.rb +56 -0
  10. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +50 -0
  11. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +155 -37
  12. data/lib/active_record/associations/has_many_association.rb +145 -75
  13. data/lib/active_record/associations/has_many_through_association.rb +283 -0
  14. data/lib/active_record/associations/has_one_association.rb +96 -0
  15. data/lib/active_record/associations.rb +1537 -304
  16. data/lib/active_record/attribute_methods.rb +328 -0
  17. data/lib/active_record/base.rb +2001 -588
  18. data/lib/active_record/calculations.rb +269 -0
  19. data/lib/active_record/callbacks.rb +169 -165
  20. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +308 -0
  21. data/lib/active_record/connection_adapters/abstract/database_statements.rb +171 -0
  22. data/lib/active_record/connection_adapters/abstract/query_cache.rb +87 -0
  23. data/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
  24. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +472 -0
  25. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +306 -0
  26. data/lib/active_record/connection_adapters/abstract_adapter.rb +125 -279
  27. data/lib/active_record/connection_adapters/mysql_adapter.rb +442 -77
  28. data/lib/active_record/connection_adapters/postgresql_adapter.rb +805 -135
  29. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
  30. data/lib/active_record/connection_adapters/sqlite_adapter.rb +353 -69
  31. data/lib/active_record/fixtures.rb +946 -100
  32. data/lib/active_record/locking/optimistic.rb +144 -0
  33. data/lib/active_record/locking/pessimistic.rb +77 -0
  34. data/lib/active_record/migration.rb +417 -0
  35. data/lib/active_record/observer.rb +142 -32
  36. data/lib/active_record/query_cache.rb +23 -0
  37. data/lib/active_record/reflection.rb +163 -70
  38. data/lib/active_record/schema.rb +58 -0
  39. data/lib/active_record/schema_dumper.rb +171 -0
  40. data/lib/active_record/serialization.rb +98 -0
  41. data/lib/active_record/serializers/json_serializer.rb +71 -0
  42. data/lib/active_record/serializers/xml_serializer.rb +315 -0
  43. data/lib/active_record/timestamp.rb +41 -0
  44. data/lib/active_record/transactions.rb +87 -57
  45. data/lib/active_record/validations.rb +909 -122
  46. data/lib/active_record/vendor/db2.rb +362 -0
  47. data/lib/active_record/vendor/mysql.rb +126 -29
  48. data/lib/active_record/version.rb +9 -0
  49. data/lib/active_record.rb +35 -7
  50. data/lib/activerecord.rb +1 -0
  51. data/test/aaa_create_tables_test.rb +72 -0
  52. data/test/abstract_unit.rb +73 -5
  53. data/test/active_schema_test_mysql.rb +43 -0
  54. data/test/adapter_test.rb +105 -0
  55. data/test/adapter_test_sqlserver.rb +95 -0
  56. data/test/aggregations_test.rb +110 -16
  57. data/test/all.sh +2 -2
  58. data/test/ar_schema_test.rb +33 -0
  59. data/test/association_inheritance_reload.rb +14 -0
  60. data/test/associations/ar_joins_test.rb +0 -0
  61. data/test/associations/callbacks_test.rb +147 -0
  62. data/test/associations/cascaded_eager_loading_test.rb +110 -0
  63. data/test/associations/eager_singularization_test.rb +145 -0
  64. data/test/associations/eager_test.rb +442 -0
  65. data/test/associations/extension_test.rb +47 -0
  66. data/test/associations/inner_join_association_test.rb +88 -0
  67. data/test/associations/join_model_test.rb +553 -0
  68. data/test/associations_test.rb +1930 -267
  69. data/test/attribute_methods_test.rb +146 -0
  70. data/test/base_test.rb +1316 -84
  71. data/test/binary_test.rb +32 -0
  72. data/test/calculations_test.rb +251 -0
  73. data/test/callbacks_test.rb +400 -0
  74. data/test/class_inheritable_attributes_test.rb +3 -4
  75. data/test/column_alias_test.rb +17 -0
  76. data/test/connection_test_firebird.rb +8 -0
  77. data/test/connection_test_mysql.rb +30 -0
  78. data/test/connections/native_db2/connection.rb +25 -0
  79. data/test/connections/native_firebird/connection.rb +26 -0
  80. data/test/connections/native_frontbase/connection.rb +27 -0
  81. data/test/connections/native_mysql/connection.rb +21 -18
  82. data/test/connections/native_openbase/connection.rb +21 -0
  83. data/test/connections/native_oracle/connection.rb +27 -0
  84. data/test/connections/native_postgresql/connection.rb +17 -18
  85. data/test/connections/native_sqlite/connection.rb +17 -16
  86. data/test/connections/native_sqlite3/connection.rb +25 -0
  87. data/test/connections/native_sqlite3/in_memory_connection.rb +18 -0
  88. data/test/connections/native_sybase/connection.rb +23 -0
  89. data/test/copy_table_test_sqlite.rb +69 -0
  90. data/test/datatype_test_postgresql.rb +203 -0
  91. data/test/date_time_test.rb +37 -0
  92. data/test/default_test_firebird.rb +16 -0
  93. data/test/defaults_test.rb +67 -0
  94. data/test/deprecated_finder_test.rb +30 -0
  95. data/test/finder_test.rb +607 -32
  96. data/test/fixtures/accounts.yml +28 -0
  97. data/test/fixtures/all/developers.yml +0 -0
  98. data/test/fixtures/all/people.csv +0 -0
  99. data/test/fixtures/all/tasks.yml +0 -0
  100. data/test/fixtures/author.rb +107 -0
  101. data/test/fixtures/author_favorites.yml +4 -0
  102. data/test/fixtures/authors.yml +7 -0
  103. data/test/fixtures/bad_fixtures/attr_with_numeric_first_char +1 -0
  104. data/test/fixtures/bad_fixtures/attr_with_spaces +1 -0
  105. data/test/fixtures/bad_fixtures/blank_line +3 -0
  106. data/test/fixtures/bad_fixtures/duplicate_attributes +3 -0
  107. data/test/fixtures/bad_fixtures/missing_value +1 -0
  108. data/test/fixtures/binaries.yml +132 -0
  109. data/test/fixtures/binary.rb +2 -0
  110. data/test/fixtures/book.rb +4 -0
  111. data/test/fixtures/books.yml +7 -0
  112. data/test/fixtures/categories/special_categories.yml +9 -0
  113. data/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
  114. data/test/fixtures/categories.yml +14 -0
  115. data/test/fixtures/categories_ordered.yml +7 -0
  116. data/test/fixtures/categories_posts.yml +23 -0
  117. data/test/fixtures/categorization.rb +5 -0
  118. data/test/fixtures/categorizations.yml +17 -0
  119. data/test/fixtures/category.rb +26 -0
  120. data/test/fixtures/citation.rb +6 -0
  121. data/test/fixtures/comment.rb +23 -0
  122. data/test/fixtures/comments.yml +59 -0
  123. data/test/fixtures/companies.yml +55 -0
  124. data/test/fixtures/company.rb +81 -4
  125. data/test/fixtures/company_in_module.rb +32 -6
  126. data/test/fixtures/computer.rb +4 -0
  127. data/test/fixtures/computers.yml +4 -0
  128. data/test/fixtures/contact.rb +16 -0
  129. data/test/fixtures/courses.yml +7 -0
  130. data/test/fixtures/customer.rb +28 -3
  131. data/test/fixtures/customers.yml +17 -0
  132. data/test/fixtures/db_definitions/db2.drop.sql +33 -0
  133. data/test/fixtures/db_definitions/db2.sql +235 -0
  134. data/test/fixtures/db_definitions/db22.drop.sql +2 -0
  135. data/test/fixtures/db_definitions/db22.sql +5 -0
  136. data/test/fixtures/db_definitions/firebird.drop.sql +65 -0
  137. data/test/fixtures/db_definitions/firebird.sql +310 -0
  138. data/test/fixtures/db_definitions/firebird2.drop.sql +2 -0
  139. data/test/fixtures/db_definitions/firebird2.sql +6 -0
  140. data/test/fixtures/db_definitions/frontbase.drop.sql +33 -0
  141. data/test/fixtures/db_definitions/frontbase.sql +273 -0
  142. data/test/fixtures/db_definitions/frontbase2.drop.sql +1 -0
  143. data/test/fixtures/db_definitions/frontbase2.sql +4 -0
  144. data/test/fixtures/db_definitions/openbase.drop.sql +2 -0
  145. data/test/fixtures/db_definitions/openbase.sql +318 -0
  146. data/test/fixtures/db_definitions/openbase2.drop.sql +2 -0
  147. data/test/fixtures/db_definitions/openbase2.sql +7 -0
  148. data/test/fixtures/db_definitions/oracle.drop.sql +67 -0
  149. data/test/fixtures/db_definitions/oracle.sql +330 -0
  150. data/test/fixtures/db_definitions/oracle2.drop.sql +2 -0
  151. data/test/fixtures/db_definitions/oracle2.sql +6 -0
  152. data/test/fixtures/db_definitions/postgresql.drop.sql +44 -0
  153. data/test/fixtures/db_definitions/postgresql.sql +217 -38
  154. data/test/fixtures/db_definitions/postgresql2.drop.sql +2 -0
  155. data/test/fixtures/db_definitions/postgresql2.sql +2 -2
  156. data/test/fixtures/db_definitions/schema.rb +354 -0
  157. data/test/fixtures/db_definitions/schema2.rb +11 -0
  158. data/test/fixtures/db_definitions/sqlite.drop.sql +33 -0
  159. data/test/fixtures/db_definitions/sqlite.sql +139 -5
  160. data/test/fixtures/db_definitions/sqlite2.drop.sql +2 -0
  161. data/test/fixtures/db_definitions/sqlite2.sql +1 -0
  162. data/test/fixtures/db_definitions/sybase.drop.sql +35 -0
  163. data/test/fixtures/db_definitions/sybase.sql +222 -0
  164. data/test/fixtures/db_definitions/sybase2.drop.sql +4 -0
  165. data/test/fixtures/db_definitions/sybase2.sql +5 -0
  166. data/test/fixtures/developer.rb +70 -6
  167. data/test/fixtures/developers.yml +21 -0
  168. data/test/fixtures/developers_projects/david_action_controller +2 -1
  169. data/test/fixtures/developers_projects/david_active_record +2 -1
  170. data/test/fixtures/developers_projects.yml +17 -0
  171. data/test/fixtures/edge.rb +5 -0
  172. data/test/fixtures/edges.yml +6 -0
  173. data/test/fixtures/entrants.yml +14 -0
  174. data/test/fixtures/example.log +1 -0
  175. data/test/fixtures/fk_test_has_fk.yml +3 -0
  176. data/test/fixtures/fk_test_has_pk.yml +2 -0
  177. data/test/fixtures/flowers.jpg +0 -0
  178. data/test/fixtures/funny_jokes.yml +10 -0
  179. data/test/fixtures/item.rb +7 -0
  180. data/test/fixtures/items.yml +4 -0
  181. data/test/fixtures/joke.rb +3 -0
  182. data/test/fixtures/keyboard.rb +3 -0
  183. data/test/fixtures/legacy_thing.rb +3 -0
  184. data/test/fixtures/legacy_things.yml +3 -0
  185. data/test/fixtures/matey.rb +4 -0
  186. data/test/fixtures/mateys.yml +4 -0
  187. data/test/fixtures/migrations/1_people_have_last_names.rb +9 -0
  188. data/test/fixtures/migrations/2_we_need_reminders.rb +12 -0
  189. data/test/fixtures/migrations/3_innocent_jointable.rb +12 -0
  190. data/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb +15 -0
  191. data/test/fixtures/migrations_with_duplicate/1_people_have_last_names.rb +9 -0
  192. data/test/fixtures/migrations_with_duplicate/2_we_need_reminders.rb +12 -0
  193. data/test/fixtures/migrations_with_duplicate/3_foo.rb +7 -0
  194. data/test/fixtures/migrations_with_duplicate/3_innocent_jointable.rb +12 -0
  195. data/test/fixtures/migrations_with_missing_versions/1000_people_have_middle_names.rb +9 -0
  196. data/test/fixtures/migrations_with_missing_versions/1_people_have_last_names.rb +9 -0
  197. data/test/fixtures/migrations_with_missing_versions/3_we_need_reminders.rb +12 -0
  198. data/test/fixtures/migrations_with_missing_versions/4_innocent_jointable.rb +12 -0
  199. data/test/fixtures/minimalistic.rb +2 -0
  200. data/test/fixtures/minimalistics.yml +2 -0
  201. data/test/fixtures/mixed_case_monkey.rb +3 -0
  202. data/test/fixtures/mixed_case_monkeys.yml +6 -0
  203. data/test/fixtures/mixins.yml +29 -0
  204. data/test/fixtures/movies.yml +7 -0
  205. data/test/fixtures/naked/csv/accounts.csv +1 -0
  206. data/test/fixtures/naked/yml/accounts.yml +1 -0
  207. data/test/fixtures/naked/yml/companies.yml +1 -0
  208. data/test/fixtures/naked/yml/courses.yml +1 -0
  209. data/test/fixtures/order.rb +4 -0
  210. data/test/fixtures/parrot.rb +13 -0
  211. data/test/fixtures/parrots.yml +27 -0
  212. data/test/fixtures/parrots_pirates.yml +7 -0
  213. data/test/fixtures/people.yml +3 -0
  214. data/test/fixtures/person.rb +4 -0
  215. data/test/fixtures/pirate.rb +5 -0
  216. data/test/fixtures/pirates.yml +9 -0
  217. data/test/fixtures/post.rb +59 -0
  218. data/test/fixtures/posts.yml +48 -0
  219. data/test/fixtures/project.rb +27 -2
  220. data/test/fixtures/projects.yml +7 -0
  221. data/test/fixtures/reader.rb +4 -0
  222. data/test/fixtures/readers.yml +4 -0
  223. data/test/fixtures/reply.rb +18 -2
  224. data/test/fixtures/reserved_words/distinct.yml +5 -0
  225. data/test/fixtures/reserved_words/distincts_selects.yml +11 -0
  226. data/test/fixtures/reserved_words/group.yml +14 -0
  227. data/test/fixtures/reserved_words/select.yml +8 -0
  228. data/test/fixtures/reserved_words/values.yml +7 -0
  229. data/test/fixtures/ship.rb +3 -0
  230. data/test/fixtures/ships.yml +5 -0
  231. data/test/fixtures/subject.rb +4 -0
  232. data/test/fixtures/subscriber.rb +4 -3
  233. data/test/fixtures/tag.rb +7 -0
  234. data/test/fixtures/tagging.rb +10 -0
  235. data/test/fixtures/taggings.yml +25 -0
  236. data/test/fixtures/tags.yml +7 -0
  237. data/test/fixtures/task.rb +3 -0
  238. data/test/fixtures/tasks.yml +7 -0
  239. data/test/fixtures/topic.rb +20 -3
  240. data/test/fixtures/topics.yml +22 -0
  241. data/test/fixtures/treasure.rb +4 -0
  242. data/test/fixtures/treasures.yml +10 -0
  243. data/test/fixtures/vertex.rb +9 -0
  244. data/test/fixtures/vertices.yml +4 -0
  245. data/test/fixtures_test.rb +574 -8
  246. data/test/inheritance_test.rb +113 -27
  247. data/test/json_serialization_test.rb +180 -0
  248. data/test/lifecycle_test.rb +56 -29
  249. data/test/locking_test.rb +273 -0
  250. data/test/method_scoping_test.rb +416 -0
  251. data/test/migration_test.rb +933 -0
  252. data/test/migration_test_firebird.rb +124 -0
  253. data/test/mixin_test.rb +95 -0
  254. data/test/modules_test.rb +23 -10
  255. data/test/multiple_db_test.rb +17 -3
  256. data/test/pk_test.rb +59 -15
  257. data/test/query_cache_test.rb +104 -0
  258. data/test/readonly_test.rb +107 -0
  259. data/test/reflection_test.rb +124 -27
  260. data/test/reserved_word_test_mysql.rb +177 -0
  261. data/test/schema_authorization_test_postgresql.rb +75 -0
  262. data/test/schema_dumper_test.rb +131 -0
  263. data/test/schema_test_postgresql.rb +64 -0
  264. data/test/serialization_test.rb +47 -0
  265. data/test/synonym_test_oracle.rb +17 -0
  266. data/test/table_name_test_sqlserver.rb +23 -0
  267. data/test/threaded_connections_test.rb +48 -0
  268. data/test/transactions_test.rb +227 -29
  269. data/test/unconnected_test.rb +14 -6
  270. data/test/validations_test.rb +1293 -32
  271. data/test/xml_serialization_test.rb +202 -0
  272. metadata +347 -143
  273. data/dev-utils/eval_debugger.rb +0 -9
  274. data/examples/associations.rb +0 -87
  275. data/examples/shared_setup.rb +0 -15
  276. data/examples/validation.rb +0 -88
  277. data/lib/active_record/deprecated_associations.rb +0 -70
  278. data/lib/active_record/support/class_attribute_accessors.rb +0 -43
  279. data/lib/active_record/support/class_inheritable_attributes.rb +0 -37
  280. data/lib/active_record/support/clean_logger.rb +0 -10
  281. data/lib/active_record/support/inflector.rb +0 -70
  282. data/lib/active_record/vendor/simple.rb +0 -702
  283. data/lib/active_record/wrappers/yaml_wrapper.rb +0 -15
  284. data/lib/active_record/wrappings.rb +0 -59
  285. data/rakefile +0 -122
  286. data/test/deprecated_associations_test.rb +0 -336
  287. data/test/fixtures/accounts/signals37 +0 -3
  288. data/test/fixtures/accounts/unknown +0 -2
  289. data/test/fixtures/companies/first_client +0 -6
  290. data/test/fixtures/companies/first_firm +0 -4
  291. data/test/fixtures/companies/second_client +0 -6
  292. data/test/fixtures/courses/java +0 -2
  293. data/test/fixtures/courses/ruby +0 -2
  294. data/test/fixtures/customers/david +0 -6
  295. data/test/fixtures/db_definitions/mysql.sql +0 -96
  296. data/test/fixtures/db_definitions/mysql2.sql +0 -4
  297. data/test/fixtures/developers/david +0 -2
  298. data/test/fixtures/developers/jamis +0 -2
  299. data/test/fixtures/entrants/first +0 -3
  300. data/test/fixtures/entrants/second +0 -3
  301. data/test/fixtures/entrants/third +0 -3
  302. data/test/fixtures/fixture_database.sqlite +0 -0
  303. data/test/fixtures/fixture_database_2.sqlite +0 -0
  304. data/test/fixtures/movies/first +0 -2
  305. data/test/fixtures/movies/second +0 -2
  306. data/test/fixtures/projects/action_controller +0 -2
  307. data/test/fixtures/projects/active_record +0 -2
  308. data/test/fixtures/topics/first +0 -9
  309. data/test/fixtures/topics/second +0 -8
  310. data/test/inflector_test.rb +0 -104
  311. data/test/thread_safety_test.rb +0 -33
@@ -0,0 +1,354 @@
1
+ ActiveRecord::Schema.define do
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
211
+
212
+ # For Firebird, set the sequence values 10000 when create_table is called;
213
+ # this prevents primary key collisions between "normally" created records
214
+ # and fixture-based (YAML) records.
215
+ if adapter_name == "Firebird"
216
+ def create_table(*args, &block)
217
+ ActiveRecord::Base.connection.create_table(*args, &block)
218
+ ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
219
+ end
220
+ end
221
+
222
+ create_table :taggings, :force => true do |t|
223
+ t.column :tag_id, :integer
224
+ t.column :super_tag_id, :integer
225
+ t.column :taggable_type, :string
226
+ t.column :taggable_id, :integer
227
+ end
228
+
229
+ create_table :tags, :force => true do |t|
230
+ t.column :name, :string
231
+ t.column :taggings_count, :integer, :default => 0
232
+ end
233
+
234
+ create_table :categorizations, :force => true do |t|
235
+ t.column :category_id, :integer
236
+ t.column :post_id, :integer
237
+ t.column :author_id, :integer
238
+ end
239
+
240
+ add_column :posts, :taggings_count, :integer, :default => 0
241
+ add_column :authors, :author_address_id, :integer
242
+
243
+ create_table :author_addresses, :force => true do |t|
244
+ t.column :author_address_id, :integer
245
+ end
246
+
247
+ create_table :author_favorites, :force => true do |t|
248
+ t.column :author_id, :integer
249
+ t.column :favorite_author_id, :integer
250
+ end
251
+
252
+ create_table :vertices, :force => true do |t|
253
+ t.column :label, :string
254
+ end
255
+
256
+ create_table :edges, :force => true do |t|
257
+ t.column :source_id, :integer, :null => false
258
+ t.column :sink_id, :integer, :null => false
259
+ end
260
+ add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index'
261
+
262
+ create_table :lock_without_defaults, :force => true do |t|
263
+ t.column :lock_version, :integer
264
+ end
265
+
266
+ create_table :lock_without_defaults_cust, :force => true do |t|
267
+ t.column :custom_lock_version, :integer
268
+ end
269
+
270
+ create_table :items, :force => true do |t|
271
+ t.column :name, :integer
272
+ end
273
+
274
+ # For sqlite 3.1.0+, make a table with a autoincrement column
275
+ if adapter_name == 'SQLite' and supports_autoincrement?
276
+ create_table :table_with_autoincrement, :force => true do |t|
277
+ t.column :name, :string
278
+ end
279
+ end
280
+
281
+ # For sqlserver 2000+, ensure real columns can be used
282
+ if adapter_name.starts_with?("SQLServer")
283
+ create_table :table_with_real_columns, :force => true do |t|
284
+ t.column :real_number, :real
285
+ end
286
+ end
287
+
288
+ create_table :audit_logs, :force => true do |t|
289
+ t.column :message, :string, :null=>false
290
+ t.column :developer_id, :integer, :null=>false
291
+ end
292
+
293
+ create_table :books, :force => true do |t|
294
+ t.column :name, :string
295
+ end
296
+
297
+ create_table :citations, :force => true do |t|
298
+ t.column :book1_id, :integer
299
+ t.column :book2_id, :integer
300
+ end
301
+
302
+ create_table :inept_wizards, :force => true do |t|
303
+ t.column :name, :string, :null => false
304
+ t.column :city, :string, :null => false
305
+ t.column :type, :string
306
+ end
307
+
308
+ create_table :parrots, :force => true do |t|
309
+ t.column :name, :string
310
+ t.column :parrot_sti_class, :string
311
+ t.column :killer_id, :integer
312
+ t.column :created_at, :datetime
313
+ t.column :created_on, :datetime
314
+ t.column :updated_at, :datetime
315
+ t.column :updated_on, :datetime
316
+ end
317
+
318
+ create_table :pirates, :force => true do |t|
319
+ t.column :catchphrase, :string
320
+ t.column :parrot_id, :integer
321
+ t.column :created_on, :datetime
322
+ t.column :updated_on, :datetime
323
+ end
324
+
325
+ create_table :parrots_pirates, :id => false, :force => true do |t|
326
+ t.column :parrot_id, :integer
327
+ t.column :pirate_id, :integer
328
+ end
329
+
330
+ create_table :treasures, :force => true do |t|
331
+ t.column :name, :string
332
+ t.column :looter_id, :integer
333
+ t.column :looter_type, :string
334
+ end
335
+
336
+ create_table :parrots_treasures, :id => false, :force => true do |t|
337
+ t.column :parrot_id, :integer
338
+ t.column :treasure_id, :integer
339
+ end
340
+
341
+ create_table :mateys, :id => false, :force => true do |t|
342
+ t.column :pirate_id, :integer
343
+ t.column :target_id, :integer
344
+ t.column :weight, :integer
345
+ end
346
+
347
+ create_table :ships, :force => true do |t|
348
+ t.string :name
349
+ t.datetime :created_at
350
+ t.datetime :created_on
351
+ t.datetime :updated_at
352
+ t.datetime :updated_on
353
+ end
354
+ end
@@ -0,0 +1,11 @@
1
+ ActiveRecord::Schema.define do
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
+ Course.connection.create_table :courses, :force => true do |t|
8
+ t.column :name, :string, :null => false
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ DROP TABLE accounts;
2
+ DROP TABLE funny_jokes;
3
+ DROP TABLE companies;
4
+ DROP TABLE topics;
5
+ DROP TABLE developers;
6
+ DROP TABLE projects;
7
+ DROP TABLE developers_projects;
8
+ DROP TABLE customers;
9
+ DROP TABLE orders;
10
+ DROP TABLE movies;
11
+ DROP TABLE subscribers;
12
+ DROP TABLE booleantests;
13
+ DROP TABLE auto_id_tests;
14
+ DROP TABLE entrants;
15
+ DROP TABLE colnametests;
16
+ DROP TABLE mixins;
17
+ DROP TABLE people;
18
+ DROP TABLE readers;
19
+ DROP TABLE binaries;
20
+ DROP TABLE computers;
21
+ DROP TABLE tasks;
22
+ DROP TABLE posts;
23
+ DROP TABLE comments;
24
+ DROP TABLE authors;
25
+ DROP TABLE categories;
26
+ DROP TABLE categories_posts;
27
+ DROP TABLE fk_test_has_fk;
28
+ DROP TABLE fk_test_has_pk;
29
+ DROP TABLE keyboards;
30
+ DROP TABLE legacy_things;
31
+ DROP TABLE numeric_data;
32
+ DROP TABLE mixed_case_monkeys;
33
+ DROP TABLE minimalistics;
@@ -4,6 +4,11 @@ CREATE TABLE 'accounts' (
4
4
  'credit_limit' INTEGER DEFAULT NULL
5
5
  );
6
6
 
7
+ CREATE TABLE 'funny_jokes' (
8
+ 'id' INTEGER PRIMARY KEY NOT NULL,
9
+ 'name' TEXT DEFAULT NULL
10
+ );
11
+
7
12
  CREATE TABLE 'companies' (
8
13
  'id' INTEGER PRIMARY KEY NOT NULL,
9
14
  'type' VARCHAR(255) DEFAULT NULL,
@@ -21,9 +26,10 @@ CREATE TABLE 'topics' (
21
26
  'author_name' VARCHAR(255) DEFAULT NULL,
22
27
  'author_email_address' VARCHAR(255) DEFAULT NULL,
23
28
  'written_on' DATETIME DEFAULT NULL,
29
+ 'bonus_time' TIME DEFAULT NULL,
24
30
  'last_read' DATE DEFAULT NULL,
25
31
  'content' TEXT,
26
- 'approved' INTEGER DEFAULT 1,
32
+ 'approved' boolean DEFAULT 't',
27
33
  'replies_count' INTEGER DEFAULT 0,
28
34
  'parent_id' INTEGER DEFAULT NULL,
29
35
  'type' VARCHAR(255) DEFAULT NULL
@@ -31,17 +37,31 @@ CREATE TABLE 'topics' (
31
37
 
32
38
  CREATE TABLE 'developers' (
33
39
  'id' INTEGER PRIMARY KEY NOT NULL,
34
- 'name' TEXT DEFAULT NULL
40
+ 'name' TEXT DEFAULT NULL,
41
+ 'salary' INTEGER DEFAULT 70000,
42
+ 'created_at' DATETIME DEFAULT NULL,
43
+ 'updated_at' DATETIME DEFAULT NULL
35
44
  );
36
45
 
37
46
  CREATE TABLE 'projects' (
38
47
  'id' INTEGER PRIMARY KEY NOT NULL,
39
- 'name' TEXT DEFAULT NULL
48
+ 'name' TEXT DEFAULT NULL,
49
+ 'type' VARCHAR(255) DEFAULT NULL
40
50
  );
41
51
 
42
52
  CREATE TABLE 'developers_projects' (
43
53
  'developer_id' INTEGER NOT NULL,
44
- 'project_id' INTEGER NOT NULL
54
+ 'project_id' INTEGER NOT NULL,
55
+ 'joined_on' DATE DEFAULT NULL,
56
+ 'access_level' INTEGER DEFAULT 1
57
+ );
58
+
59
+
60
+ CREATE TABLE 'orders' (
61
+ 'id' INTEGER PRIMARY KEY NOT NULL,
62
+ 'name' VARCHAR(255) DEFAULT NULL,
63
+ 'billing_customer_id' INTEGER DEFAULT NULL,
64
+ 'shipping_customer_id' INTEGER DEFAULT NULL
45
65
  );
46
66
 
47
67
  CREATE TABLE 'customers' (
@@ -50,7 +70,8 @@ CREATE TABLE 'customers' (
50
70
  'balance' INTEGER DEFAULT 0,
51
71
  'address_street' TEXT DEFAULT NULL,
52
72
  'address_city' TEXT DEFAULT NULL,
53
- 'address_country' TEXT DEFAULT NULL
73
+ 'address_country' TEXT DEFAULT NULL,
74
+ 'gps_location' TEXT DEFAULT NULL
54
75
  );
55
76
 
56
77
  CREATE TABLE 'movies' (
@@ -83,3 +104,116 @@ CREATE TABLE 'colnametests' (
83
104
  'id' INTEGER NOT NULL PRIMARY KEY,
84
105
  'references' INTEGER NOT NULL
85
106
  );
107
+
108
+ CREATE TABLE 'mixins' (
109
+ 'id' INTEGER NOT NULL PRIMARY KEY,
110
+ 'parent_id' INTEGER DEFAULT NULL,
111
+ 'type' VARCHAR(40) DEFAULT NULL,
112
+ 'pos' INTEGER DEFAULT NULL,
113
+ 'lft' INTEGER DEFAULT NULL,
114
+ 'rgt' INTEGER DEFAULT NULL,
115
+ 'root_id' INTEGER DEFAULT NULL,
116
+ 'created_at' DATETIME DEFAULT NULL,
117
+ 'updated_at' DATETIME DEFAULT NULL
118
+ );
119
+
120
+ CREATE TABLE 'people' (
121
+ 'id' INTEGER NOT NULL PRIMARY KEY,
122
+ 'first_name' VARCHAR(40) DEFAULT NULL,
123
+ 'lock_version' INTEGER NOT NULL DEFAULT 0
124
+ );
125
+
126
+ CREATE TABLE 'readers' (
127
+ 'id' INTEGER NOT NULL PRIMARY KEY,
128
+ 'post_id' INTEGER NOT NULL,
129
+ 'person_id' INTEGER NOT NULL
130
+ );
131
+
132
+ CREATE TABLE 'binaries' (
133
+ 'id' INTEGER NOT NULL PRIMARY KEY,
134
+ 'data' BLOB DEFAULT NULL
135
+ );
136
+
137
+ CREATE TABLE 'computers' (
138
+ 'id' INTEGER NOT NULL PRIMARY KEY,
139
+ 'developer' INTEGER NOT NULL,
140
+ 'extendedWarranty' INTEGER NOT NULL
141
+ );
142
+
143
+ CREATE TABLE 'posts' (
144
+ 'id' INTEGER NOT NULL PRIMARY KEY,
145
+ 'author_id' INTEGER,
146
+ 'title' VARCHAR(255) NOT NULL,
147
+ 'type' VARCHAR(255) DEFAULT NULL,
148
+ 'body' TEXT NOT NULL
149
+ );
150
+
151
+ CREATE TABLE 'comments' (
152
+ 'id' INTEGER NOT NULL PRIMARY KEY,
153
+ 'post_id' INTEGER NOT NULL,
154
+ 'type' VARCHAR(255) DEFAULT NULL,
155
+ 'body' TEXT NOT NULL
156
+ );
157
+
158
+ CREATE TABLE 'authors' (
159
+ 'id' INTEGER NOT NULL PRIMARY KEY,
160
+ 'name' VARCHAR(255) NOT NULL
161
+ );
162
+
163
+ CREATE TABLE 'tasks' (
164
+ 'id' INTEGER NOT NULL PRIMARY KEY,
165
+ 'starting' DATETIME DEFAULT NULL,
166
+ 'ending' DATETIME DEFAULT NULL
167
+ );
168
+
169
+ CREATE TABLE 'categories' (
170
+ 'id' INTEGER NOT NULL PRIMARY KEY,
171
+ 'name' VARCHAR(255) NOT NULL,
172
+ 'type' VARCHAR(255) DEFAULT NULL
173
+ );
174
+
175
+ CREATE TABLE 'categories_posts' (
176
+ 'category_id' INTEGER NOT NULL,
177
+ 'post_id' INTEGER NOT NULL
178
+ );
179
+
180
+ CREATE TABLE 'fk_test_has_pk' (
181
+ 'id' INTEGER NOT NULL PRIMARY KEY
182
+ );
183
+
184
+ CREATE TABLE 'fk_test_has_fk' (
185
+ 'id' INTEGER NOT NULL PRIMARY KEY,
186
+ 'fk_id' INTEGER NOT NULL,
187
+
188
+ FOREIGN KEY ('fk_id') REFERENCES 'fk_test_has_pk'('id')
189
+ );
190
+
191
+ CREATE TABLE 'keyboards' (
192
+ 'key_number' INTEGER PRIMARY KEY NOT NULL,
193
+ 'name' VARCHAR(255) DEFAULT NULL
194
+ );
195
+
196
+ --Altered lock_version column name.
197
+ CREATE TABLE 'legacy_things' (
198
+ 'id' INTEGER NOT NULL PRIMARY KEY,
199
+ 'tps_report_number' INTEGER DEFAULT NULL,
200
+ 'version' INTEGER NOT NULL DEFAULT 0
201
+ );
202
+
203
+ CREATE TABLE 'numeric_data' (
204
+ 'id' INTEGER NOT NULL PRIMARY KEY,
205
+ 'bank_balance' DECIMAL(10,2),
206
+ 'big_bank_balance' DECIMAL(15,2),
207
+ 'world_population' DECIMAL(10),
208
+ 'my_house_population' DECIMAL(2),
209
+ 'decimal_number_with_default' DECIMAL(3,2) DEFAULT 2.78
210
+ );
211
+
212
+ CREATE TABLE mixed_case_monkeys (
213
+ 'monkeyID' INTEGER NOT NULL PRIMARY KEY,
214
+ 'fleaCount' INTEGER
215
+ );
216
+
217
+ CREATE TABLE minimalistics (
218
+ 'id' INTEGER NOT NULL PRIMARY KEY
219
+ );
@@ -0,0 +1,2 @@
1
+ DROP TABLE courses;
2
+
@@ -2,3 +2,4 @@ CREATE TABLE 'courses' (
2
2
  'id' INTEGER NOT NULL PRIMARY KEY,
3
3
  'name' VARCHAR(255) NOT NULL
4
4
  );
5
+
@@ -0,0 +1,35 @@
1
+ DROP TABLE accounts
2
+ DROP TABLE funny_jokes
3
+ DROP TABLE companies
4
+ DROP TABLE topics
5
+ DROP TABLE developers
6
+ DROP TABLE projects
7
+ DROP TABLE developers_projects
8
+ DROP TABLE customers
9
+ DROP TABLE orders
10
+ DROP TABLE movies
11
+ DROP TABLE subscribers
12
+ DROP TABLE booleantests
13
+ DROP TABLE auto_id_tests
14
+ DROP TABLE entrants
15
+ DROP TABLE colnametests
16
+ DROP TABLE mixins
17
+ DROP TABLE people
18
+ DROP TABLE readers
19
+ DROP TABLE binaries
20
+ DROP TABLE computers
21
+ DROP TABLE tasks
22
+ DROP TABLE posts
23
+ DROP TABLE comments
24
+ DROP TABLE authors
25
+ DROP TABLE categories
26
+ DROP TABLE categories_posts
27
+ DROP TABLE fk_test_has_fk
28
+ DROP TABLE fk_test_has_pk
29
+ DROP TABLE keyboards
30
+ DROP TABLE legacy_things
31
+ DROP TABLE numeric_data
32
+ DROP TABLE mixed_case_monkeys
33
+ DROP TABLE minimalistics
34
+ DROP TABLE schema_info
35
+ go