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,318 @@
1
+ CREATE TABLE accounts (
2
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
3
+ firm_id integer,
4
+ credit_limit integer
5
+ )
6
+ go
7
+ CREATE PRIMARY KEY accounts (id)
8
+ go
9
+
10
+ CREATE TABLE funny_jokes (
11
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
12
+ name char(50) DEFAULT NULL
13
+ )
14
+ go
15
+ CREATE PRIMARY KEY funny_jokes (id)
16
+ go
17
+
18
+ CREATE TABLE companies (
19
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
20
+ type char(50),
21
+ ruby_type char(50),
22
+ firm_id integer,
23
+ name char(50),
24
+ client_of integer,
25
+ rating integer default 1
26
+ )
27
+ go
28
+ CREATE PRIMARY KEY companies (id)
29
+ go
30
+
31
+ CREATE TABLE developers_projects (
32
+ developer_id integer NOT NULL,
33
+ project_id integer NOT NULL,
34
+ joined_on date,
35
+ access_level integer default 1
36
+ )
37
+ go
38
+
39
+ CREATE TABLE developers (
40
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
41
+ name char(100),
42
+ salary integer DEFAULT 70000,
43
+ created_at datetime,
44
+ updated_at datetime
45
+ )
46
+ go
47
+ CREATE PRIMARY KEY developers (id)
48
+ go
49
+
50
+ CREATE TABLE projects (
51
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
52
+ name char(100),
53
+ type char(255)
54
+ )
55
+ go
56
+ CREATE PRIMARY KEY projects (id)
57
+ go
58
+
59
+ CREATE TABLE topics (
60
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
61
+ title char(255),
62
+ author_name char(255),
63
+ author_email_address char(255),
64
+ written_on datetime,
65
+ bonus_time time,
66
+ last_read date,
67
+ content char(4096),
68
+ approved boolean default true,
69
+ replies_count integer default 0,
70
+ parent_id integer,
71
+ type char(50)
72
+ )
73
+ go
74
+ CREATE PRIMARY KEY topics (id)
75
+ go
76
+
77
+ CREATE TABLE customers (
78
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
79
+ name char,
80
+ balance integer default 0,
81
+ address_street char,
82
+ address_city char,
83
+ address_country char,
84
+ gps_location char
85
+ )
86
+ go
87
+ CREATE PRIMARY KEY customers (id)
88
+ go
89
+
90
+ CREATE TABLE orders (
91
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
92
+ name char,
93
+ billing_customer_id integer,
94
+ shipping_customer_id integer
95
+ )
96
+ go
97
+ CREATE PRIMARY KEY orders (id)
98
+ go
99
+
100
+ CREATE TABLE movies (
101
+ movieid integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
102
+ name text
103
+ )
104
+ go
105
+ CREATE PRIMARY KEY movies (movieid)
106
+ go
107
+
108
+ CREATE TABLE subscribers (
109
+ nick CHAR(100) NOT NULL DEFAULT _rowid,
110
+ name CHAR(100)
111
+ )
112
+ go
113
+ CREATE PRIMARY KEY subscribers (nick)
114
+ go
115
+
116
+ CREATE TABLE booleantests (
117
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
118
+ value boolean
119
+ )
120
+ go
121
+ CREATE PRIMARY KEY booleantests (id)
122
+ go
123
+
124
+ CREATE TABLE defaults (
125
+ id integer UNIQUE INDEX ,
126
+ modified_date date default CURDATE(),
127
+ modified_date_function date default NOW(),
128
+ fixed_date date default '2004-01-01',
129
+ modified_time timestamp default NOW(),
130
+ modified_time_function timestamp default NOW(),
131
+ fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
132
+ char1 char(1) default 'Y',
133
+ char2 char(50) default 'a char field',
134
+ char3 text default 'a text field',
135
+ positive_integer integer default 1,
136
+ negative_integer integer default -1,
137
+ decimal_number money default 2.78
138
+ )
139
+ go
140
+ CREATE PRIMARY KEY defaults (id)
141
+ go
142
+
143
+ CREATE TABLE auto_id_tests (
144
+ auto_id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
145
+ value integer
146
+ )
147
+ go
148
+ CREATE PRIMARY KEY auto_id_tests (auto_id)
149
+ go
150
+
151
+ CREATE TABLE entrants (
152
+ id integer NOT NULL UNIQUE INDEX,
153
+ name text NOT NULL,
154
+ course_id integer NOT NULL
155
+ )
156
+ go
157
+ CREATE PRIMARY KEY entrants (id)
158
+ go
159
+
160
+ CREATE TABLE colnametests (
161
+ id integer UNIQUE INDEX ,
162
+ references integer NOT NULL
163
+ )
164
+ go
165
+ CREATE PRIMARY KEY colnametests (id)
166
+ go
167
+
168
+ CREATE TABLE mixins (
169
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
170
+ parent_id integer,
171
+ type char,
172
+ pos integer,
173
+ lft integer,
174
+ rgt integer,
175
+ root_id integer,
176
+ created_at timestamp,
177
+ updated_at timestamp
178
+ )
179
+ go
180
+ CREATE PRIMARY KEY mixins (id)
181
+ go
182
+
183
+ CREATE TABLE people (
184
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
185
+ first_name text,
186
+ lock_version integer default 0
187
+ )
188
+ go
189
+ CREATE PRIMARY KEY people (id)
190
+ go
191
+
192
+ CREATE TABLE readers (
193
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
194
+ post_id integer NOT NULL,
195
+ person_id integer NOT NULL
196
+ )
197
+ go
198
+ CREATE PRIMARY KEY readers (id)
199
+ go
200
+
201
+ CREATE TABLE binaries (
202
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
203
+ data object
204
+ )
205
+ go
206
+ CREATE PRIMARY KEY binaries (id)
207
+ go
208
+
209
+ CREATE TABLE computers (
210
+ id integer UNIQUE INDEX ,
211
+ developer integer NOT NULL,
212
+ extendedWarranty integer NOT NULL
213
+ )
214
+ go
215
+
216
+ CREATE TABLE posts (
217
+ id integer UNIQUE INDEX ,
218
+ author_id integer,
219
+ title char(255),
220
+ type char(255),
221
+ body text
222
+ )
223
+ go
224
+
225
+ CREATE TABLE comments (
226
+ id integer UNIQUE INDEX ,
227
+ post_id integer,
228
+ type char(255),
229
+ body text
230
+ )
231
+ go
232
+
233
+ CREATE TABLE authors (
234
+ id integer UNIQUE INDEX ,
235
+ name char(255) default NULL
236
+ )
237
+ go
238
+
239
+ CREATE TABLE tasks (
240
+ id integer NOT NULL UNIQUE INDEX DEFAULT _rowid,
241
+ starting datetime,
242
+ ending datetime
243
+ )
244
+ go
245
+ CREATE PRIMARY KEY tasks (id)
246
+ go
247
+
248
+ CREATE TABLE categories (
249
+ id integer UNIQUE INDEX ,
250
+ name char(255),
251
+ type char(255)
252
+ )
253
+ go
254
+
255
+ CREATE TABLE categories_posts (
256
+ category_id integer NOT NULL,
257
+ post_id integer NOT NULL
258
+ )
259
+ go
260
+
261
+ CREATE TABLE fk_test_has_pk (
262
+ id INTEGER NOT NULL DEFAULT _rowid
263
+ )
264
+ go
265
+ CREATE PRIMARY KEY fk_test_has_pk (id)
266
+ go
267
+
268
+ CREATE TABLE fk_test_has_fk (
269
+ id INTEGER NOT NULL DEFAULT _rowid,
270
+ fk_id INTEGER NOT NULL REFERENCES fk_test_has_pk.id
271
+ )
272
+ go
273
+ CREATE PRIMARY KEY fk_test_has_fk (id)
274
+ go
275
+
276
+ CREATE TABLE keyboards (
277
+ key_number integer UNIQUE INDEX DEFAULT _rowid,
278
+ name char(50)
279
+ )
280
+ go
281
+ CREATE PRIMARY KEY keyboards (key_number)
282
+ go
283
+
284
+ CREATE TABLE legacy_things (
285
+ id INTEGER NOT NULL DEFAULT _rowid,
286
+ tps_report_number INTEGER default NULL,
287
+ version integer NOT NULL default 0
288
+ )
289
+ go
290
+ CREATE PRIMARY KEY legacy_things (id)
291
+ go
292
+
293
+ CREATE TABLE numeric_data (
294
+ id INTEGER NOT NULL DEFAULT _rowid,
295
+ bank_balance MONEY,
296
+ big_bank_balance MONEY,
297
+ world_population longlong,
298
+ my_house_population longlong,
299
+ decimal_number_with_default MONEY DEFAULT 2.78
300
+ );
301
+ go
302
+ CREATE PRIMARY KEY numeric_data (id)
303
+ go
304
+
305
+ CREATE TABLE mixed_case_monkeys (
306
+ monkeyID INTEGER NOT NULL DEFAULT _rowid,
307
+ fleaCount INTEGER
308
+ );
309
+ go
310
+ CREATE PRIMARY KEY mixed_case_monkeys (monkeyID)
311
+ go
312
+
313
+ CREATE TABLE minimalistics (
314
+ id INTEGER NOT NULL DEFAULT _rowid
315
+ );
316
+ go
317
+ CREATE PRIMARY KEY minimalistics (id)
318
+ go
@@ -0,0 +1,2 @@
1
+ DROP TABLE courses
2
+ go
@@ -0,0 +1,7 @@
1
+ CREATE TABLE courses (
2
+ id integer UNIQUE INDEX DEFAULT _rowid,
3
+ name text
4
+ )
5
+ go
6
+ CREATE PRIMARY KEY courses (id)
7
+ go
@@ -0,0 +1,67 @@
1
+ drop table accounts;
2
+ drop table funny_jokes;
3
+ drop table companies;
4
+ drop table topics;
5
+ drop synonym subjects;
6
+ drop table developers_projects;
7
+ drop table computers;
8
+ drop table developers;
9
+ drop table projects;
10
+ drop table customers;
11
+ drop table orders;
12
+ drop table movies;
13
+ drop table subscribers;
14
+ drop table booleantests;
15
+ drop table auto_id_tests;
16
+ drop table entrants;
17
+ drop table colnametests;
18
+ drop table mixins;
19
+ drop table people;
20
+ drop table readers;
21
+ drop table binaries;
22
+ drop table comments;
23
+ drop table authors;
24
+ drop table tasks;
25
+ drop table categories_posts;
26
+ drop table categories;
27
+ drop table posts;
28
+ drop table fk_test_has_pk;
29
+ drop table fk_test_has_fk;
30
+ drop table keyboards;
31
+ drop table legacy_things;
32
+ drop table numeric_data;
33
+ drop table mixed_case_monkeys;
34
+ drop table minimalistics;
35
+
36
+ drop sequence accounts_seq;
37
+ drop sequence funny_jokes_seq;
38
+ drop sequence companies_nonstd_seq;
39
+ drop sequence topics_seq;
40
+ drop sequence developers_seq;
41
+ drop sequence projects_seq;
42
+ drop sequence developers_projects_seq;
43
+ drop sequence customers_seq;
44
+ drop sequence orders_seq;
45
+ drop sequence movies_seq;
46
+ drop sequence subscribers_seq;
47
+ drop sequence booleantests_seq;
48
+ drop sequence auto_id_tests_seq;
49
+ drop sequence entrants_seq;
50
+ drop sequence colnametests_seq;
51
+ drop sequence mixins_seq;
52
+ drop sequence people_seq;
53
+ drop sequence binaries_seq;
54
+ drop sequence posts_seq;
55
+ drop sequence comments_seq;
56
+ drop sequence authors_seq;
57
+ drop sequence tasks_seq;
58
+ drop sequence computers_seq;
59
+ drop sequence categories_seq;
60
+ drop sequence categories_posts_seq;
61
+ drop sequence fk_test_has_pk_seq;
62
+ drop sequence fk_test_has_fk_seq;
63
+ drop sequence keyboards_seq;
64
+ drop sequence legacy_things_seq;
65
+ drop sequence numeric_data_seq;
66
+ drop sequence mixed_case_monkeys_seq;
67
+ drop sequence minimalistics_seq;
@@ -0,0 +1,330 @@
1
+ create table companies (
2
+ id integer not null,
3
+ type varchar(50) default null,
4
+ ruby_type varchar(50) default null,
5
+ firm_id integer default null references companies initially deferred disable,
6
+ name varchar(50) default null,
7
+ client_of integer default null references companies initially deferred disable,
8
+ companies_count integer default 0,
9
+ rating integer default 1,
10
+ primary key (id)
11
+ );
12
+
13
+ -- non-standard sequence name used to test set_sequence_name
14
+ --
15
+ create sequence companies_nonstd_seq minvalue 10000;
16
+
17
+ create table funny_jokes (
18
+ id integer not null,
19
+ name varchar(50) default null,
20
+ primary key (id)
21
+ );
22
+ create sequence funny_jokes_seq minvalue 10000;
23
+
24
+ create table accounts (
25
+ id integer not null,
26
+ firm_id integer default null references companies initially deferred disable,
27
+ credit_limit integer default null
28
+ );
29
+ create sequence accounts_seq minvalue 10000;
30
+
31
+ create table topics (
32
+ id integer not null,
33
+ title varchar(255) default null,
34
+ author_name varchar(255) default null,
35
+ author_email_address varchar(255) default null,
36
+ written_on timestamp default null,
37
+ bonus_time timestamp default null,
38
+ last_read timestamp default null,
39
+ content varchar(4000),
40
+ approved number(1) default 1,
41
+ replies_count integer default 0,
42
+ parent_id integer references topics initially deferred disable,
43
+ type varchar(50) default null,
44
+ primary key (id)
45
+ );
46
+ -- try again for 8i
47
+ create table topics (
48
+ id integer not null,
49
+ title varchar(255) default null,
50
+ author_name varchar(255) default null,
51
+ author_email_address varchar(255) default null,
52
+ written_on date default null,
53
+ bonus_time date default null,
54
+ last_read date default null,
55
+ content varchar(4000),
56
+ approved number(1) default 1,
57
+ replies_count integer default 0,
58
+ parent_id integer references topics initially deferred disable,
59
+ type varchar(50) default null,
60
+ primary key (id)
61
+ );
62
+ create sequence topics_seq minvalue 10000;
63
+
64
+ create synonym subjects for topics;
65
+
66
+ create table developers (
67
+ id integer not null,
68
+ name varchar(100) default null,
69
+ salary integer default 70000,
70
+ created_at timestamp default null,
71
+ updated_at timestamp default null,
72
+ primary key (id)
73
+ );
74
+ create sequence developers_seq minvalue 10000;
75
+
76
+ create table projects (
77
+ id integer not null,
78
+ name varchar(100) default null,
79
+ type varchar(255) default null,
80
+ primary key (id)
81
+ );
82
+ create sequence projects_seq minvalue 10000;
83
+
84
+ create table developers_projects (
85
+ developer_id integer not null references developers initially deferred disable,
86
+ project_id integer not null references projects initially deferred disable,
87
+ joined_on timestamp default null,
88
+ access_level integer default 1
89
+ );
90
+ -- Try again for 8i
91
+ create table developers_projects (
92
+ developer_id integer not null references developers initially deferred disable,
93
+ project_id integer not null references projects initially deferred disable,
94
+ joined_on date default null
95
+ );
96
+ create sequence developers_projects_seq minvalue 10000;
97
+
98
+ create table orders (
99
+ id integer not null,
100
+ name varchar(100) default null,
101
+ billing_customer_id integer default null,
102
+ shipping_customer_id integer default null,
103
+ primary key (id)
104
+ );
105
+ create sequence orders_seq minvalue 10000;
106
+
107
+ create table customers (
108
+ id integer not null,
109
+ name varchar(100) default null,
110
+ balance integer default 0,
111
+ address_street varchar(100) default null,
112
+ address_city varchar(100) default null,
113
+ address_country varchar(100) default null,
114
+ gps_location varchar(100) default null,
115
+ primary key (id)
116
+ );
117
+ create sequence customers_seq minvalue 10000;
118
+
119
+ create table movies (
120
+ movieid integer not null,
121
+ name varchar(100) default null,
122
+ primary key (movieid)
123
+ );
124
+ create sequence movies_seq minvalue 10000;
125
+
126
+ create table subscribers (
127
+ nick varchar(100) not null,
128
+ name varchar(100) default null,
129
+ primary key (nick)
130
+ );
131
+ create sequence subscribers_seq minvalue 10000;
132
+
133
+ create table booleantests (
134
+ id integer not null,
135
+ value integer default null,
136
+ primary key (id)
137
+ );
138
+ create sequence booleantests_seq minvalue 10000;
139
+
140
+ CREATE TABLE defaults (
141
+ id integer not null,
142
+ modified_date date default sysdate,
143
+ modified_date_function date default sysdate,
144
+ fixed_date date default to_date('2004-01-01', 'YYYY-MM-DD'),
145
+ modified_time date default sysdate,
146
+ modified_time_function date default sysdate,
147
+ fixed_time date default TO_DATE('2004-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'),
148
+ char1 varchar2(1) default 'Y',
149
+ char2 varchar2(50) default 'a varchar field',
150
+ char3 clob default 'a text field',
151
+ positive_integer integer default 1,
152
+ negative_integer integer default -1,
153
+ decimal_number number(3,2) default 2.78
154
+ );
155
+ create sequence defaults_seq minvalue 10000;
156
+
157
+ create table auto_id_tests (
158
+ auto_id integer not null,
159
+ value integer default null,
160
+ primary key (auto_id)
161
+ );
162
+ create sequence auto_id_tests_seq minvalue 10000;
163
+
164
+ create table entrants (
165
+ id integer not null primary key,
166
+ name varchar(255) not null,
167
+ course_id integer not null
168
+ );
169
+ create sequence entrants_seq minvalue 10000;
170
+
171
+ create table colnametests (
172
+ id integer not null,
173
+ references integer not null,
174
+ primary key (id)
175
+ );
176
+ create sequence colnametests_seq minvalue 10000;
177
+
178
+ create table mixins (
179
+ id integer not null,
180
+ parent_id integer default null references mixins initially deferred disable,
181
+ type varchar(40) default null,
182
+ pos integer default null,
183
+ lft integer default null,
184
+ rgt integer default null,
185
+ root_id integer default null,
186
+ created_at timestamp default null,
187
+ updated_at timestamp default null,
188
+ primary key (id)
189
+ );
190
+ -- try again for 8i
191
+ create table mixins (
192
+ id integer not null,
193
+ parent_id integer default null references mixins initially deferred disable,
194
+ type varchar(40) default null,
195
+ pos integer default null,
196
+ lft integer default null,
197
+ rgt integer default null,
198
+ root_id integer default null,
199
+ created_at date default null,
200
+ updated_at date default null,
201
+ primary key (id)
202
+ );
203
+ create sequence mixins_seq minvalue 10000;
204
+
205
+ create table people (
206
+ id integer not null,
207
+ first_name varchar(40) null,
208
+ lock_version integer default 0,
209
+ primary key (id)
210
+ );
211
+ create sequence people_seq minvalue 10000;
212
+
213
+ create table readers (
214
+ id integer not null,
215
+ post_id integer not null,
216
+ person_id integer not null,
217
+ primary key (id)
218
+ );
219
+ create sequence readers_seq minvalue 10000;
220
+
221
+ create table binaries (
222
+ id integer not null,
223
+ data blob null,
224
+ primary key (id)
225
+ );
226
+ create sequence binaries_seq minvalue 10000;
227
+
228
+ create table computers (
229
+ id integer not null primary key,
230
+ developer integer not null references developers initially deferred disable,
231
+ "extendedWarranty" integer not null
232
+ );
233
+ create sequence computers_seq minvalue 10000;
234
+
235
+ create table posts (
236
+ id integer not null primary key,
237
+ author_id integer default null,
238
+ title varchar(255) default null,
239
+ type varchar(255) default null,
240
+ body varchar(3000) default null
241
+ );
242
+ create sequence posts_seq minvalue 10000;
243
+
244
+ create table comments (
245
+ id integer not null primary key,
246
+ post_id integer default null,
247
+ type varchar(255) default null,
248
+ body varchar(3000) default null
249
+ );
250
+ create sequence comments_seq minvalue 10000;
251
+
252
+ create table authors (
253
+ id integer not null primary key,
254
+ name varchar(255) default null
255
+ );
256
+ create sequence authors_seq minvalue 10000;
257
+
258
+ create table tasks (
259
+ id integer not null primary key,
260
+ starting date default null,
261
+ ending date default null
262
+ );
263
+ create sequence tasks_seq minvalue 10000;
264
+
265
+ create table categories (
266
+ id integer not null primary key,
267
+ name varchar(255) default null,
268
+ type varchar(255) default null
269
+ );
270
+ create sequence categories_seq minvalue 10000;
271
+
272
+ create table categories_posts (
273
+ category_id integer not null references categories initially deferred disable,
274
+ post_id integer not null references posts initially deferred disable
275
+ );
276
+ create sequence categories_posts_seq minvalue 10000;
277
+
278
+ create table fk_test_has_pk (
279
+ id integer not null primary key
280
+ );
281
+ create sequence fk_test_has_pk_seq minvalue 10000;
282
+
283
+ create table fk_test_has_fk (
284
+ id integer not null primary key,
285
+ fk_id integer not null references fk_test_has_fk initially deferred disable
286
+ );
287
+ create sequence fk_test_has_fk_seq minvalue 10000;
288
+
289
+ create table keyboards (
290
+ key_number integer not null,
291
+ name varchar(50) default null
292
+ );
293
+ create sequence keyboards_seq minvalue 10000;
294
+
295
+ create table test_oracle_defaults (
296
+ id integer not null primary key,
297
+ test_char char(1) default 'X' not null,
298
+ test_string varchar2(20) default 'hello' not null,
299
+ test_int integer default 3 not null
300
+ );
301
+ create sequence test_oracle_defaults_seq minvalue 10000;
302
+
303
+ --This table has an altered lock_version column name.
304
+ create table legacy_things (
305
+ id integer not null primary key,
306
+ tps_report_number integer default null,
307
+ version integer default 0
308
+ );
309
+ create sequence legacy_things_seq minvalue 10000;
310
+
311
+ CREATE TABLE numeric_data (
312
+ id integer NOT NULL PRIMARY KEY,
313
+ bank_balance decimal(10,2),
314
+ big_bank_balance decimal(15,2),
315
+ world_population decimal(10),
316
+ my_house_population decimal(2),
317
+ decimal_number_with_default decimal(3,2) DEFAULT 2.78
318
+ );
319
+ create sequence numeric_data_seq minvalue 10000;
320
+
321
+ CREATE TABLE mixed_case_monkeys (
322
+ "monkeyID" INTEGER NOT NULL PRIMARY KEY,
323
+ "fleaCount" INTEGER
324
+ );
325
+ create sequence mixed_case_monkeys_seq minvalue 10000;
326
+
327
+ CREATE TABLE minimalistics (
328
+ id INTEGER NOT NULL PRIMARY KEY
329
+ );
330
+ create sequence minimalistics_seq minvalue 10000;