activerecord 2.0.5 → 2.1.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 (289) hide show
  1. data/CHANGELOG +168 -6
  2. data/README +27 -22
  3. data/RUNNING_UNIT_TESTS +7 -4
  4. data/Rakefile +22 -25
  5. data/lib/active_record.rb +8 -2
  6. data/lib/active_record/aggregations.rb +21 -12
  7. data/lib/active_record/association_preload.rb +277 -0
  8. data/lib/active_record/associations.rb +481 -295
  9. data/lib/active_record/associations/association_collection.rb +162 -37
  10. data/lib/active_record/associations/association_proxy.rb +71 -7
  11. data/lib/active_record/associations/belongs_to_association.rb +5 -3
  12. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +5 -6
  13. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +12 -64
  14. data/lib/active_record/associations/has_many_association.rb +8 -73
  15. data/lib/active_record/associations/has_many_through_association.rb +68 -117
  16. data/lib/active_record/associations/has_one_association.rb +7 -5
  17. data/lib/active_record/associations/has_one_through_association.rb +28 -0
  18. data/lib/active_record/attribute_methods.rb +69 -19
  19. data/lib/active_record/base.rb +496 -275
  20. data/lib/active_record/calculations.rb +28 -21
  21. data/lib/active_record/callbacks.rb +9 -38
  22. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +3 -2
  23. data/lib/active_record/connection_adapters/abstract/database_statements.rb +2 -2
  24. data/lib/active_record/connection_adapters/abstract/query_cache.rb +6 -0
  25. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +232 -45
  26. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +141 -27
  27. data/lib/active_record/connection_adapters/abstract_adapter.rb +9 -13
  28. data/lib/active_record/connection_adapters/mysql_adapter.rb +57 -24
  29. data/lib/active_record/connection_adapters/postgresql_adapter.rb +143 -42
  30. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -1
  31. data/lib/active_record/connection_adapters/sqlite_adapter.rb +18 -10
  32. data/lib/active_record/dirty.rb +158 -0
  33. data/lib/active_record/fixtures.rb +121 -156
  34. data/lib/active_record/locking/optimistic.rb +14 -11
  35. data/lib/active_record/locking/pessimistic.rb +2 -2
  36. data/lib/active_record/migration.rb +157 -77
  37. data/lib/active_record/named_scope.rb +163 -0
  38. data/lib/active_record/observer.rb +19 -5
  39. data/lib/active_record/reflection.rb +34 -14
  40. data/lib/active_record/schema.rb +7 -14
  41. data/lib/active_record/schema_dumper.rb +4 -4
  42. data/lib/active_record/serialization.rb +5 -5
  43. data/lib/active_record/serializers/json_serializer.rb +37 -28
  44. data/lib/active_record/serializers/xml_serializer.rb +52 -29
  45. data/lib/active_record/test_case.rb +36 -0
  46. data/lib/active_record/timestamp.rb +4 -4
  47. data/lib/active_record/transactions.rb +3 -3
  48. data/lib/active_record/validations.rb +182 -248
  49. data/lib/active_record/version.rb +2 -2
  50. data/test/{fixtures → assets}/example.log +0 -0
  51. data/test/{fixtures → assets}/flowers.jpg +0 -0
  52. data/test/cases/aaa_create_tables_test.rb +24 -0
  53. data/test/cases/active_schema_test_mysql.rb +95 -0
  54. data/test/cases/active_schema_test_postgresql.rb +24 -0
  55. data/test/{adapter_test.rb → cases/adapter_test.rb} +15 -14
  56. data/test/{adapter_test_sqlserver.rb → cases/adapter_test_sqlserver.rb} +95 -95
  57. data/test/{aggregations_test.rb → cases/aggregations_test.rb} +20 -20
  58. data/test/{ar_schema_test.rb → cases/ar_schema_test.rb} +6 -6
  59. data/test/cases/associations/belongs_to_associations_test.rb +412 -0
  60. data/test/{associations → cases/associations}/callbacks_test.rb +24 -10
  61. data/test/{associations → cases/associations}/cascaded_eager_loading_test.rb +18 -17
  62. data/test/cases/associations/eager_load_nested_include_test.rb +83 -0
  63. data/test/{associations → cases/associations}/eager_singularization_test.rb +5 -5
  64. data/test/{associations → cases/associations}/eager_test.rb +216 -51
  65. data/test/{associations → cases/associations}/extension_test.rb +8 -8
  66. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +684 -0
  67. data/test/cases/associations/has_many_associations_test.rb +932 -0
  68. data/test/cases/associations/has_many_through_associations_test.rb +190 -0
  69. data/test/cases/associations/has_one_associations_test.rb +323 -0
  70. data/test/cases/associations/has_one_through_associations_test.rb +74 -0
  71. data/test/{associations → cases/associations}/inner_join_association_test.rb +20 -20
  72. data/test/{associations → cases/associations}/join_model_test.rb +175 -35
  73. data/test/cases/associations_test.rb +262 -0
  74. data/test/{attribute_methods_test.rb → cases/attribute_methods_test.rb} +103 -11
  75. data/test/{base_test.rb → cases/base_test.rb} +338 -191
  76. data/test/{binary_test.rb → cases/binary_test.rb} +6 -4
  77. data/test/{calculations_test.rb → cases/calculations_test.rb} +35 -23
  78. data/test/{callbacks_test.rb → cases/callbacks_test.rb} +7 -7
  79. data/test/{class_inheritable_attributes_test.rb → cases/class_inheritable_attributes_test.rb} +3 -3
  80. data/test/{column_alias_test.rb → cases/column_alias_test.rb} +3 -3
  81. data/test/{connection_test_firebird.rb → cases/connection_test_firebird.rb} +2 -2
  82. data/test/{connection_test_mysql.rb → cases/connection_test_mysql.rb} +2 -2
  83. data/test/{copy_table_test_sqlite.rb → cases/copy_table_test_sqlite.rb} +13 -13
  84. data/test/{datatype_test_postgresql.rb → cases/datatype_test_postgresql.rb} +8 -8
  85. data/test/{date_time_test.rb → cases/date_time_test.rb} +5 -5
  86. data/test/{default_test_firebird.rb → cases/default_test_firebird.rb} +3 -3
  87. data/test/{defaults_test.rb → cases/defaults_test.rb} +8 -6
  88. data/test/{deprecated_finder_test.rb → cases/deprecated_finder_test.rb} +3 -3
  89. data/test/cases/dirty_test.rb +163 -0
  90. data/test/cases/finder_respond_to_test.rb +76 -0
  91. data/test/{finder_test.rb → cases/finder_test.rb} +266 -33
  92. data/test/{fixtures_test.rb → cases/fixtures_test.rb} +88 -72
  93. data/test/cases/helper.rb +47 -0
  94. data/test/{inheritance_test.rb → cases/inheritance_test.rb} +61 -17
  95. data/test/cases/invalid_date_test.rb +24 -0
  96. data/test/{json_serialization_test.rb → cases/json_serialization_test.rb} +36 -11
  97. data/test/{lifecycle_test.rb → cases/lifecycle_test.rb} +16 -13
  98. data/test/{locking_test.rb → cases/locking_test.rb} +17 -10
  99. data/test/{method_scoping_test.rb → cases/method_scoping_test.rb} +75 -39
  100. data/test/{migration_test.rb → cases/migration_test.rb} +420 -80
  101. data/test/{migration_test_firebird.rb → cases/migration_test_firebird.rb} +3 -3
  102. data/test/{mixin_test.rb → cases/mixin_test.rb} +7 -6
  103. data/test/{modules_test.rb → cases/modules_test.rb} +11 -6
  104. data/test/{multiple_db_test.rb → cases/multiple_db_test.rb} +5 -5
  105. data/test/cases/named_scope_test.rb +157 -0
  106. data/test/{pk_test.rb → cases/pk_test.rb} +10 -10
  107. data/test/{query_cache_test.rb → cases/query_cache_test.rb} +12 -10
  108. data/test/{readonly_test.rb → cases/readonly_test.rb} +11 -11
  109. data/test/{reflection_test.rb → cases/reflection_test.rb} +15 -14
  110. data/test/{reserved_word_test_mysql.rb → cases/reserved_word_test_mysql.rb} +4 -5
  111. data/test/{schema_authorization_test_postgresql.rb → cases/schema_authorization_test_postgresql.rb} +5 -5
  112. data/test/cases/schema_dumper_test.rb +138 -0
  113. data/test/cases/schema_test_postgresql.rb +102 -0
  114. data/test/{serialization_test.rb → cases/serialization_test.rb} +7 -7
  115. data/test/{synonym_test_oracle.rb → cases/synonym_test_oracle.rb} +5 -5
  116. data/test/{table_name_test_sqlserver.rb → cases/table_name_test_sqlserver.rb} +3 -3
  117. data/test/{threaded_connections_test.rb → cases/threaded_connections_test.rb} +7 -7
  118. data/test/{transactions_test.rb → cases/transactions_test.rb} +31 -5
  119. data/test/{unconnected_test.rb → cases/unconnected_test.rb} +2 -2
  120. data/test/{validations_test.rb → cases/validations_test.rb} +141 -39
  121. data/test/{xml_serialization_test.rb → cases/xml_serialization_test.rb} +12 -12
  122. data/test/config.rb +5 -0
  123. data/test/connections/native_db2/connection.rb +1 -1
  124. data/test/connections/native_firebird/connection.rb +1 -1
  125. data/test/connections/native_frontbase/connection.rb +1 -1
  126. data/test/connections/native_mysql/connection.rb +1 -1
  127. data/test/connections/native_openbase/connection.rb +1 -1
  128. data/test/connections/native_oracle/connection.rb +1 -1
  129. data/test/connections/native_postgresql/connection.rb +1 -3
  130. data/test/connections/native_sqlite/connection.rb +2 -2
  131. data/test/connections/native_sqlite3/connection.rb +2 -2
  132. data/test/connections/native_sqlite3/in_memory_connection.rb +3 -3
  133. data/test/connections/native_sybase/connection.rb +1 -1
  134. data/test/fixtures/author_addresses.yml +5 -0
  135. data/test/fixtures/authors.yml +2 -0
  136. data/test/fixtures/clubs.yml +6 -0
  137. data/test/fixtures/jobs.yml +7 -0
  138. data/test/fixtures/members.yml +4 -0
  139. data/test/fixtures/memberships.yml +20 -0
  140. data/test/fixtures/owners.yml +7 -0
  141. data/test/fixtures/people.yml +4 -1
  142. data/test/fixtures/pets.yml +14 -0
  143. data/test/fixtures/posts.yml +1 -0
  144. data/test/fixtures/price_estimates.yml +7 -0
  145. data/test/fixtures/readers.yml +5 -0
  146. data/test/fixtures/references.yml +17 -0
  147. data/test/fixtures/sponsors.yml +9 -0
  148. data/test/fixtures/subscribers.yml +7 -0
  149. data/test/fixtures/subscriptions.yml +12 -0
  150. data/test/fixtures/taggings.yml +4 -1
  151. data/test/fixtures/topics.yml +22 -2
  152. data/test/fixtures/warehouse-things.yml +3 -0
  153. data/test/{fixtures/migrations_with_decimal → migrations/decimal}/1_give_me_big_numbers.rb +0 -0
  154. data/test/{fixtures/migrations_with_duplicate → migrations/duplicate}/1_people_have_last_names.rb +1 -1
  155. data/test/{fixtures/migrations_with_duplicate → migrations/duplicate}/2_we_need_reminders.rb +1 -1
  156. data/test/{fixtures/migrations_with_duplicate → migrations/duplicate}/3_foo.rb +0 -0
  157. data/test/{fixtures/migrations → migrations/duplicate}/3_innocent_jointable.rb +0 -0
  158. data/test/migrations/duplicate_names/20080507052938_chunky.rb +7 -0
  159. data/test/migrations/duplicate_names/20080507053028_chunky.rb +7 -0
  160. data/test/{fixtures/migrations_with_duplicate → migrations/interleaved/pass_1}/3_innocent_jointable.rb +0 -0
  161. data/test/{fixtures/migrations → migrations/interleaved/pass_2}/1_people_have_last_names.rb +1 -1
  162. data/test/{fixtures/migrations_with_missing_versions/4_innocent_jointable.rb → migrations/interleaved/pass_2/3_innocent_jointable.rb} +0 -0
  163. data/test/{fixtures/migrations_with_missing_versions → migrations/interleaved/pass_3}/1_people_have_last_names.rb +1 -1
  164. data/test/migrations/interleaved/pass_3/2_i_raise_on_down.rb +8 -0
  165. data/test/migrations/interleaved/pass_3/3_innocent_jointable.rb +12 -0
  166. data/test/{fixtures/migrations_with_missing_versions → migrations/missing}/1000_people_have_middle_names.rb +1 -1
  167. data/test/migrations/missing/1_people_have_last_names.rb +9 -0
  168. data/test/{fixtures/migrations_with_missing_versions → migrations/missing}/3_we_need_reminders.rb +1 -1
  169. data/test/migrations/missing/4_innocent_jointable.rb +12 -0
  170. data/test/migrations/valid/1_people_have_last_names.rb +9 -0
  171. data/test/{fixtures/migrations → migrations/valid}/2_we_need_reminders.rb +1 -1
  172. data/test/migrations/valid/3_innocent_jointable.rb +12 -0
  173. data/test/{fixtures → models}/author.rb +28 -4
  174. data/test/{fixtures → models}/auto_id.rb +0 -0
  175. data/test/{fixtures → models}/binary.rb +0 -0
  176. data/test/{fixtures → models}/book.rb +0 -0
  177. data/test/{fixtures → models}/categorization.rb +0 -0
  178. data/test/{fixtures → models}/category.rb +8 -5
  179. data/test/{fixtures → models}/citation.rb +0 -0
  180. data/test/models/club.rb +7 -0
  181. data/test/{fixtures → models}/column_name.rb +0 -0
  182. data/test/{fixtures → models}/comment.rb +5 -3
  183. data/test/{fixtures → models}/company.rb +15 -6
  184. data/test/{fixtures → models}/company_in_module.rb +5 -3
  185. data/test/{fixtures → models}/computer.rb +0 -1
  186. data/test/{fixtures → models}/contact.rb +1 -1
  187. data/test/{fixtures → models}/course.rb +0 -0
  188. data/test/{fixtures → models}/customer.rb +8 -8
  189. data/test/{fixtures → models}/default.rb +0 -0
  190. data/test/{fixtures → models}/developer.rb +14 -10
  191. data/test/{fixtures → models}/edge.rb +0 -0
  192. data/test/{fixtures → models}/entrant.rb +0 -0
  193. data/test/models/guid.rb +2 -0
  194. data/test/{fixtures → models}/item.rb +0 -0
  195. data/test/models/job.rb +5 -0
  196. data/test/{fixtures → models}/joke.rb +0 -0
  197. data/test/{fixtures → models}/keyboard.rb +0 -0
  198. data/test/{fixtures → models}/legacy_thing.rb +0 -0
  199. data/test/{fixtures → models}/matey.rb +0 -0
  200. data/test/models/member.rb +9 -0
  201. data/test/models/membership.rb +9 -0
  202. data/test/{fixtures → models}/minimalistic.rb +0 -0
  203. data/test/{fixtures → models}/mixed_case_monkey.rb +0 -0
  204. data/test/{fixtures → models}/movie.rb +0 -0
  205. data/test/{fixtures → models}/order.rb +2 -2
  206. data/test/models/owner.rb +4 -0
  207. data/test/{fixtures → models}/parrot.rb +0 -0
  208. data/test/models/person.rb +10 -0
  209. data/test/models/pet.rb +4 -0
  210. data/test/models/pirate.rb +9 -0
  211. data/test/{fixtures → models}/post.rb +23 -2
  212. data/test/models/price_estimate.rb +3 -0
  213. data/test/{fixtures → models}/project.rb +1 -0
  214. data/test/{fixtures → models}/reader.rb +0 -0
  215. data/test/models/reference.rb +4 -0
  216. data/test/{fixtures → models}/reply.rb +7 -5
  217. data/test/{fixtures → models}/ship.rb +0 -0
  218. data/test/models/sponsor.rb +4 -0
  219. data/test/{fixtures → models}/subject.rb +0 -0
  220. data/test/{fixtures → models}/subscriber.rb +2 -0
  221. data/test/models/subscription.rb +4 -0
  222. data/test/{fixtures → models}/tag.rb +0 -0
  223. data/test/{fixtures → models}/tagging.rb +0 -0
  224. data/test/{fixtures → models}/task.rb +0 -0
  225. data/test/{fixtures → models}/topic.rb +32 -4
  226. data/test/{fixtures → models}/treasure.rb +2 -0
  227. data/test/{fixtures → models}/vertex.rb +0 -0
  228. data/test/models/warehouse_thing.rb +5 -0
  229. data/test/schema/mysql_specific_schema.rb +12 -0
  230. data/test/schema/postgresql_specific_schema.rb +103 -0
  231. data/test/schema/schema.rb +421 -0
  232. data/test/schema/schema2.rb +6 -0
  233. data/test/schema/sqlite_specific_schema.rb +25 -0
  234. data/test/schema/sqlserver_specific_schema.rb +5 -0
  235. metadata +192 -176
  236. data/test/aaa_create_tables_test.rb +0 -72
  237. data/test/abstract_unit.rb +0 -84
  238. data/test/active_schema_test_mysql.rb +0 -46
  239. data/test/all.sh +0 -8
  240. data/test/association_inheritance_reload.rb +0 -14
  241. data/test/associations_test.rb +0 -2177
  242. data/test/fixtures/bad_fixtures/attr_with_numeric_first_char +0 -1
  243. data/test/fixtures/bad_fixtures/attr_with_spaces +0 -1
  244. data/test/fixtures/bad_fixtures/blank_line +0 -3
  245. data/test/fixtures/bad_fixtures/duplicate_attributes +0 -3
  246. data/test/fixtures/bad_fixtures/missing_value +0 -1
  247. data/test/fixtures/db_definitions/db2.drop.sql +0 -33
  248. data/test/fixtures/db_definitions/db2.sql +0 -235
  249. data/test/fixtures/db_definitions/db22.drop.sql +0 -2
  250. data/test/fixtures/db_definitions/db22.sql +0 -5
  251. data/test/fixtures/db_definitions/firebird.drop.sql +0 -65
  252. data/test/fixtures/db_definitions/firebird.sql +0 -310
  253. data/test/fixtures/db_definitions/firebird2.drop.sql +0 -2
  254. data/test/fixtures/db_definitions/firebird2.sql +0 -6
  255. data/test/fixtures/db_definitions/frontbase.drop.sql +0 -33
  256. data/test/fixtures/db_definitions/frontbase.sql +0 -273
  257. data/test/fixtures/db_definitions/frontbase2.drop.sql +0 -1
  258. data/test/fixtures/db_definitions/frontbase2.sql +0 -4
  259. data/test/fixtures/db_definitions/openbase.drop.sql +0 -2
  260. data/test/fixtures/db_definitions/openbase.sql +0 -318
  261. data/test/fixtures/db_definitions/openbase2.drop.sql +0 -2
  262. data/test/fixtures/db_definitions/openbase2.sql +0 -7
  263. data/test/fixtures/db_definitions/oracle.drop.sql +0 -67
  264. data/test/fixtures/db_definitions/oracle.sql +0 -330
  265. data/test/fixtures/db_definitions/oracle2.drop.sql +0 -2
  266. data/test/fixtures/db_definitions/oracle2.sql +0 -6
  267. data/test/fixtures/db_definitions/postgresql.drop.sql +0 -44
  268. data/test/fixtures/db_definitions/postgresql.sql +0 -292
  269. data/test/fixtures/db_definitions/postgresql2.drop.sql +0 -2
  270. data/test/fixtures/db_definitions/postgresql2.sql +0 -4
  271. data/test/fixtures/db_definitions/schema.rb +0 -354
  272. data/test/fixtures/db_definitions/schema2.rb +0 -11
  273. data/test/fixtures/db_definitions/sqlite.drop.sql +0 -33
  274. data/test/fixtures/db_definitions/sqlite.sql +0 -219
  275. data/test/fixtures/db_definitions/sqlite2.drop.sql +0 -2
  276. data/test/fixtures/db_definitions/sqlite2.sql +0 -5
  277. data/test/fixtures/db_definitions/sybase.drop.sql +0 -35
  278. data/test/fixtures/db_definitions/sybase.sql +0 -222
  279. data/test/fixtures/db_definitions/sybase2.drop.sql +0 -4
  280. data/test/fixtures/db_definitions/sybase2.sql +0 -5
  281. data/test/fixtures/developers_projects/david_action_controller +0 -3
  282. data/test/fixtures/developers_projects/david_active_record +0 -3
  283. data/test/fixtures/developers_projects/jamis_active_record +0 -2
  284. data/test/fixtures/person.rb +0 -4
  285. data/test/fixtures/pirate.rb +0 -5
  286. data/test/fixtures/subscribers/first +0 -2
  287. data/test/fixtures/subscribers/second +0 -2
  288. data/test/schema_dumper_test.rb +0 -131
  289. data/test/schema_test_postgresql.rb +0 -64
@@ -1,2 +0,0 @@
1
- DROP TABLE courses;
2
- DROP GENERATOR courses_seq;
@@ -1,6 +0,0 @@
1
- CREATE TABLE courses (
2
- id BIGINT NOT NULL PRIMARY KEY,
3
- name VARCHAR(255) NOT NULL
4
- );
5
- CREATE GENERATOR courses_seq;
6
- SET GENERATOR courses_seq TO 10000;
@@ -1,33 +0,0 @@
1
- DROP TABLE accounts CASCADE;
2
- DROP TABLE funny_jokes CASCADE;
3
- DROP TABLE companies CASCADE;
4
- DROP TABLE topics CASCADE;
5
- DROP TABLE developers CASCADE;
6
- DROP TABLE projects CASCADE;
7
- DROP TABLE developers_projects CASCADE;
8
- DROP TABLE orders CASCADE;
9
- DROP TABLE customers CASCADE;
10
- DROP TABLE movies CASCADE;
11
- DROP TABLE subscribers CASCADE;
12
- DROP TABLE booleantests CASCADE;
13
- DROP TABLE auto_id_tests CASCADE;
14
- DROP TABLE entrants CASCADE;
15
- DROP TABLE colnametests CASCADE;
16
- DROP TABLE mixins CASCADE;
17
- DROP TABLE people CASCADE;
18
- DROP TABLE readers CASCADE;
19
- DROP TABLE binaries CASCADE;
20
- DROP TABLE computers CASCADE;
21
- DROP TABLE posts CASCADE;
22
- DROP TABLE comments CASCADE;
23
- DROP TABLE authors CASCADE;
24
- DROP TABLE tasks CASCADE;
25
- DROP TABLE categories CASCADE;
26
- DROP TABLE categories_posts CASCADE;
27
- DROP TABLE fk_test_has_fk CASCADE;
28
- DROP TABLE fk_test_has_pk CASCADE;
29
- DROP TABLE keyboards CASCADE;
30
- DROP TABLE legacy_things CASCADE;
31
- DROP TABLE numeric_data CASCADE;
32
- DROP TABLE mixed_case_monkeys CASCADE;
33
- DROP TABLE minimalistics CASCADE;
@@ -1,273 +0,0 @@
1
- CREATE TABLE accounts (
2
- id integer DEFAULT unique,
3
- firm_id integer,
4
- credit_limit integer,
5
- PRIMARY KEY (id)
6
- );
7
- SET UNIQUE FOR accounts(id);
8
-
9
- CREATE TABLE funny_jokes (
10
- id integer DEFAULT unique,
11
- firm_id integer default NULL,
12
- name character varying(50),
13
- PRIMARY KEY (id)
14
- );
15
- SET UNIQUE FOR funny_jokes(id);
16
-
17
- CREATE TABLE companies (
18
- id integer DEFAULT unique,
19
- "type" character varying(50),
20
- "ruby_type" character varying(50),
21
- firm_id integer,
22
- name character varying(50),
23
- client_of integer,
24
- rating integer default 1,
25
- PRIMARY KEY (id)
26
- );
27
- SET UNIQUE FOR companies(id);
28
-
29
- CREATE TABLE topics (
30
- id integer DEFAULT unique,
31
- title character varying(255),
32
- author_name character varying(255),
33
- author_email_address character varying(255),
34
- written_on timestamp,
35
- bonus_time time,
36
- last_read date,
37
- content varchar(65536),
38
- approved boolean default true,
39
- replies_count integer default 0,
40
- parent_id integer,
41
- "type" character varying(50),
42
- PRIMARY KEY (id)
43
- );
44
- SET UNIQUE FOR topics(id);
45
-
46
- CREATE TABLE developers (
47
- id integer DEFAULT unique,
48
- name character varying(100),
49
- salary integer DEFAULT 70000,
50
- created_at timestamp,
51
- updated_at timestamp,
52
- PRIMARY KEY (id)
53
- );
54
- SET UNIQUE FOR developers(id);
55
-
56
- CREATE TABLE projects (
57
- id integer DEFAULT unique,
58
- name character varying(100),
59
- type varchar(255),
60
- PRIMARY KEY (id)
61
- );
62
- SET UNIQUE FOR projects(id);
63
-
64
- CREATE TABLE developers_projects (
65
- developer_id integer NOT NULL,
66
- project_id integer NOT NULL,
67
- joined_on date,
68
- access_level integer default 1
69
- );
70
-
71
- CREATE TABLE orders (
72
- id integer DEFAULT unique,
73
- name character varying(100),
74
- billing_customer_id integer,
75
- shipping_customer_id integer,
76
- PRIMARY KEY (id)
77
- );
78
- SET UNIQUE FOR orders(id);
79
-
80
- CREATE TABLE customers (
81
- id integer DEFAULT unique,
82
- name character varying(100),
83
- balance integer default 0,
84
- address_street character varying(100),
85
- address_city character varying(100),
86
- address_country character varying(100),
87
- gps_location character varying(100),
88
- PRIMARY KEY (id)
89
- );
90
- SET UNIQUE FOR customers(id);
91
-
92
- CREATE TABLE movies (
93
- movieid integer DEFAULT unique,
94
- name varchar(65536),
95
- PRIMARY KEY (movieid)
96
- );
97
- SET UNIQUE FOR movies(movieid);
98
-
99
- CREATE TABLE subscribers (
100
- nick varchar(65536) NOT NULL,
101
- name varchar(65536),
102
- PRIMARY KEY (nick)
103
- );
104
-
105
- CREATE TABLE booleantests (
106
- id integer DEFAULT unique,
107
- value boolean,
108
- PRIMARY KEY (id)
109
- );
110
- SET UNIQUE FOR booleantests(id);
111
-
112
- CREATE TABLE auto_id_tests (
113
- auto_id integer DEFAULT unique,
114
- value integer,
115
- PRIMARY KEY (auto_id)
116
- );
117
- SET UNIQUE FOR auto_id_tests(auto_id);
118
-
119
- CREATE TABLE entrants (
120
- id integer DEFAULT unique,
121
- name varchar(65536),
122
- course_id integer,
123
- PRIMARY KEY (id)
124
- );
125
- SET UNIQUE FOR entrants(id);
126
-
127
- CREATE TABLE colnametests (
128
- id integer DEFAULT unique,
129
- "references" integer NOT NULL,
130
- PRIMARY KEY (id)
131
- );
132
- SET UNIQUE FOR colnametests(id);
133
-
134
- CREATE TABLE mixins (
135
- id integer DEFAULT unique,
136
- parent_id integer,
137
- type character varying(100),
138
- pos integer,
139
- lft integer,
140
- rgt integer,
141
- root_id integer,
142
- created_at timestamp,
143
- updated_at timestamp,
144
- PRIMARY KEY (id)
145
- );
146
- SET UNIQUE FOR mixins(id);
147
-
148
- CREATE TABLE people (
149
- id integer DEFAULT unique,
150
- first_name varchar(65536),
151
- lock_version integer default 0,
152
- PRIMARY KEY (id)
153
- );
154
- SET UNIQUE FOR people(id);
155
-
156
- CREATE TABLE readers (
157
- id integer DEFAULT unique,
158
- post_id INTEGER NOT NULL,
159
- person_id INTEGER NOT NULL,
160
- PRIMARY KEY (id)
161
- );
162
- SET UNIQUE FOR readers(id);
163
-
164
- CREATE TABLE binaries (
165
- id integer DEFAULT unique,
166
- data BLOB,
167
- PRIMARY KEY (id)
168
- );
169
- SET UNIQUE FOR binaries(id);
170
-
171
- CREATE TABLE computers (
172
- id integer DEFAULT unique,
173
- developer integer NOT NULL,
174
- "extendedWarranty" integer NOT NULL,
175
- PRIMARY KEY (id)
176
- );
177
- SET UNIQUE FOR computers(id);
178
-
179
- CREATE TABLE posts (
180
- id integer DEFAULT unique,
181
- author_id integer,
182
- title varchar(255),
183
- type varchar(255),
184
- body varchar(65536),
185
- PRIMARY KEY (id)
186
- );
187
- SET UNIQUE FOR posts(id);
188
-
189
- CREATE TABLE comments (
190
- id integer DEFAULT unique,
191
- post_id integer,
192
- type varchar(255),
193
- body varchar(65536),
194
- PRIMARY KEY (id)
195
- );
196
- SET UNIQUE FOR comments(id);
197
-
198
- CREATE TABLE authors (
199
- id integer DEFAULT unique,
200
- name varchar(255) default NULL,
201
- PRIMARY KEY (id)
202
- );
203
- SET UNIQUE FOR authors(id);
204
-
205
- CREATE TABLE tasks (
206
- id integer DEFAULT unique,
207
- starting timestamp,
208
- ending timestamp,
209
- PRIMARY KEY (id)
210
- );
211
- SET UNIQUE FOR tasks(id);
212
-
213
- CREATE TABLE categories (
214
- id integer DEFAULT unique,
215
- name varchar(255),
216
- type varchar(255),
217
- PRIMARY KEY (id)
218
- );
219
- SET UNIQUE FOR categories(id);
220
-
221
- CREATE TABLE categories_posts (
222
- category_id integer NOT NULL,
223
- post_id integer NOT NULL
224
- );
225
-
226
- CREATE TABLE fk_test_has_pk (
227
- id INTEGER NOT NULL PRIMARY KEY
228
- );
229
- SET UNIQUE FOR fk_test_has_pk(id);
230
-
231
- CREATE TABLE fk_test_has_fk (
232
- id INTEGER NOT NULL PRIMARY KEY,
233
- fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id)
234
- );
235
- SET UNIQUE FOR fk_test_has_fk(id);
236
-
237
- CREATE TABLE keyboards (
238
- key_number integer DEFAULT unique,
239
- "name" character varying(50),
240
- PRIMARY KEY (key_number)
241
- );
242
- SET UNIQUE FOR keyboards(key_number);
243
-
244
- create table "legacy_things"
245
- (
246
- "id" int,
247
- "tps_report_number" int default NULL,
248
- "version" int default 0 not null,
249
- primary key ("id")
250
- );
251
- SET UNIQUE FOR legacy_things(id);
252
-
253
- CREATE TABLE "numeric_data" (
254
- "id" integer NOT NULL
255
- "bank_balance" DECIMAL(10,2),
256
- "big_bank_balance" DECIMAL(15,2),
257
- "world_population" DECIMAL(10),
258
- "my_house_population" DECIMAL(2),
259
- "decimal_number_with_default" DECIMAL(3,2) DEFAULT 2.78,
260
- primary key ("id")
261
- );
262
- SET UNIQUE FOR numeric_data(id);
263
-
264
- CREATE TABLE mixed_case_monkeys (
265
- "monkeyID" integer DEFAULT unique,
266
- "fleaCount" integer
267
- );
268
- SET UNIQUE FOR mixed_case_monkeys("monkeyID");
269
-
270
- CREATE TABLE minimalistics (
271
- "id" integer NOT NULL
272
- );
273
- SET UNIQUE FOR minimalistics("id");
@@ -1 +0,0 @@
1
- DROP TABLE courses CASCADE;
@@ -1,4 +0,0 @@
1
- CREATE TABLE courses (
2
- id integer DEFAULT unique,
3
- name varchar(100)
4
- );
@@ -1,2 +0,0 @@
1
- DROP ALL
2
- go
@@ -1,318 +0,0 @@
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