activerecord_authorails 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) hide show
  1. data/CHANGELOG +3043 -0
  2. data/README +360 -0
  3. data/RUNNING_UNIT_TESTS +64 -0
  4. data/Rakefile +226 -0
  5. data/examples/associations.png +0 -0
  6. data/examples/associations.rb +87 -0
  7. data/examples/shared_setup.rb +15 -0
  8. data/examples/validation.rb +85 -0
  9. data/install.rb +30 -0
  10. data/lib/active_record.rb +85 -0
  11. data/lib/active_record/acts/list.rb +244 -0
  12. data/lib/active_record/acts/nested_set.rb +211 -0
  13. data/lib/active_record/acts/tree.rb +89 -0
  14. data/lib/active_record/aggregations.rb +191 -0
  15. data/lib/active_record/associations.rb +1637 -0
  16. data/lib/active_record/associations/association_collection.rb +190 -0
  17. data/lib/active_record/associations/association_proxy.rb +158 -0
  18. data/lib/active_record/associations/belongs_to_association.rb +56 -0
  19. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +50 -0
  20. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +169 -0
  21. data/lib/active_record/associations/has_many_association.rb +210 -0
  22. data/lib/active_record/associations/has_many_through_association.rb +247 -0
  23. data/lib/active_record/associations/has_one_association.rb +80 -0
  24. data/lib/active_record/attribute_methods.rb +75 -0
  25. data/lib/active_record/base.rb +2164 -0
  26. data/lib/active_record/calculations.rb +270 -0
  27. data/lib/active_record/callbacks.rb +367 -0
  28. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +279 -0
  29. data/lib/active_record/connection_adapters/abstract/database_statements.rb +130 -0
  30. data/lib/active_record/connection_adapters/abstract/quoting.rb +58 -0
  31. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +343 -0
  32. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +310 -0
  33. data/lib/active_record/connection_adapters/abstract_adapter.rb +161 -0
  34. data/lib/active_record/connection_adapters/db2_adapter.rb +228 -0
  35. data/lib/active_record/connection_adapters/firebird_adapter.rb +728 -0
  36. data/lib/active_record/connection_adapters/frontbase_adapter.rb +861 -0
  37. data/lib/active_record/connection_adapters/mysql_adapter.rb +414 -0
  38. data/lib/active_record/connection_adapters/openbase_adapter.rb +350 -0
  39. data/lib/active_record/connection_adapters/oracle_adapter.rb +689 -0
  40. data/lib/active_record/connection_adapters/postgresql_adapter.rb +584 -0
  41. data/lib/active_record/connection_adapters/sqlite_adapter.rb +407 -0
  42. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +591 -0
  43. data/lib/active_record/connection_adapters/sybase_adapter.rb +662 -0
  44. data/lib/active_record/deprecated_associations.rb +104 -0
  45. data/lib/active_record/deprecated_finders.rb +44 -0
  46. data/lib/active_record/fixtures.rb +628 -0
  47. data/lib/active_record/locking/optimistic.rb +106 -0
  48. data/lib/active_record/locking/pessimistic.rb +77 -0
  49. data/lib/active_record/migration.rb +394 -0
  50. data/lib/active_record/observer.rb +178 -0
  51. data/lib/active_record/query_cache.rb +64 -0
  52. data/lib/active_record/reflection.rb +222 -0
  53. data/lib/active_record/schema.rb +58 -0
  54. data/lib/active_record/schema_dumper.rb +149 -0
  55. data/lib/active_record/timestamp.rb +51 -0
  56. data/lib/active_record/transactions.rb +136 -0
  57. data/lib/active_record/validations.rb +843 -0
  58. data/lib/active_record/vendor/db2.rb +362 -0
  59. data/lib/active_record/vendor/mysql.rb +1214 -0
  60. data/lib/active_record/vendor/simple.rb +693 -0
  61. data/lib/active_record/version.rb +9 -0
  62. data/lib/active_record/wrappers/yaml_wrapper.rb +15 -0
  63. data/lib/active_record/wrappings.rb +58 -0
  64. data/lib/active_record/xml_serialization.rb +308 -0
  65. data/test/aaa_create_tables_test.rb +59 -0
  66. data/test/abstract_unit.rb +77 -0
  67. data/test/active_schema_test_mysql.rb +31 -0
  68. data/test/adapter_test.rb +87 -0
  69. data/test/adapter_test_sqlserver.rb +81 -0
  70. data/test/aggregations_test.rb +95 -0
  71. data/test/all.sh +8 -0
  72. data/test/ar_schema_test.rb +33 -0
  73. data/test/association_inheritance_reload.rb +14 -0
  74. data/test/associations/callbacks_test.rb +126 -0
  75. data/test/associations/cascaded_eager_loading_test.rb +138 -0
  76. data/test/associations/eager_test.rb +393 -0
  77. data/test/associations/extension_test.rb +42 -0
  78. data/test/associations/join_model_test.rb +497 -0
  79. data/test/associations_test.rb +1809 -0
  80. data/test/attribute_methods_test.rb +49 -0
  81. data/test/base_test.rb +1586 -0
  82. data/test/binary_test.rb +37 -0
  83. data/test/calculations_test.rb +219 -0
  84. data/test/callbacks_test.rb +377 -0
  85. data/test/class_inheritable_attributes_test.rb +32 -0
  86. data/test/column_alias_test.rb +17 -0
  87. data/test/connection_test_firebird.rb +8 -0
  88. data/test/connections/native_db2/connection.rb +25 -0
  89. data/test/connections/native_firebird/connection.rb +26 -0
  90. data/test/connections/native_frontbase/connection.rb +27 -0
  91. data/test/connections/native_mysql/connection.rb +24 -0
  92. data/test/connections/native_openbase/connection.rb +21 -0
  93. data/test/connections/native_oracle/connection.rb +27 -0
  94. data/test/connections/native_postgresql/connection.rb +23 -0
  95. data/test/connections/native_sqlite/connection.rb +34 -0
  96. data/test/connections/native_sqlite3/connection.rb +34 -0
  97. data/test/connections/native_sqlite3/in_memory_connection.rb +18 -0
  98. data/test/connections/native_sqlserver/connection.rb +23 -0
  99. data/test/connections/native_sqlserver_odbc/connection.rb +25 -0
  100. data/test/connections/native_sybase/connection.rb +23 -0
  101. data/test/copy_table_sqlite.rb +64 -0
  102. data/test/datatype_test_postgresql.rb +52 -0
  103. data/test/default_test_firebird.rb +16 -0
  104. data/test/defaults_test.rb +60 -0
  105. data/test/deprecated_associations_test.rb +396 -0
  106. data/test/deprecated_finder_test.rb +151 -0
  107. data/test/empty_date_time_test.rb +25 -0
  108. data/test/finder_test.rb +504 -0
  109. data/test/fixtures/accounts.yml +28 -0
  110. data/test/fixtures/author.rb +99 -0
  111. data/test/fixtures/author_favorites.yml +4 -0
  112. data/test/fixtures/authors.yml +7 -0
  113. data/test/fixtures/auto_id.rb +4 -0
  114. data/test/fixtures/bad_fixtures/attr_with_numeric_first_char +1 -0
  115. data/test/fixtures/bad_fixtures/attr_with_spaces +1 -0
  116. data/test/fixtures/bad_fixtures/blank_line +3 -0
  117. data/test/fixtures/bad_fixtures/duplicate_attributes +3 -0
  118. data/test/fixtures/bad_fixtures/missing_value +1 -0
  119. data/test/fixtures/binary.rb +2 -0
  120. data/test/fixtures/categories.yml +14 -0
  121. data/test/fixtures/categories/special_categories.yml +9 -0
  122. data/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
  123. data/test/fixtures/categories_ordered.yml +7 -0
  124. data/test/fixtures/categories_posts.yml +23 -0
  125. data/test/fixtures/categorization.rb +5 -0
  126. data/test/fixtures/categorizations.yml +17 -0
  127. data/test/fixtures/category.rb +20 -0
  128. data/test/fixtures/column_name.rb +3 -0
  129. data/test/fixtures/comment.rb +23 -0
  130. data/test/fixtures/comments.yml +59 -0
  131. data/test/fixtures/companies.yml +55 -0
  132. data/test/fixtures/company.rb +107 -0
  133. data/test/fixtures/company_in_module.rb +59 -0
  134. data/test/fixtures/computer.rb +3 -0
  135. data/test/fixtures/computers.yml +4 -0
  136. data/test/fixtures/course.rb +3 -0
  137. data/test/fixtures/courses.yml +7 -0
  138. data/test/fixtures/customer.rb +55 -0
  139. data/test/fixtures/customers.yml +17 -0
  140. data/test/fixtures/db_definitions/db2.drop.sql +32 -0
  141. data/test/fixtures/db_definitions/db2.sql +231 -0
  142. data/test/fixtures/db_definitions/db22.drop.sql +2 -0
  143. data/test/fixtures/db_definitions/db22.sql +5 -0
  144. data/test/fixtures/db_definitions/firebird.drop.sql +63 -0
  145. data/test/fixtures/db_definitions/firebird.sql +304 -0
  146. data/test/fixtures/db_definitions/firebird2.drop.sql +2 -0
  147. data/test/fixtures/db_definitions/firebird2.sql +6 -0
  148. data/test/fixtures/db_definitions/frontbase.drop.sql +32 -0
  149. data/test/fixtures/db_definitions/frontbase.sql +268 -0
  150. data/test/fixtures/db_definitions/frontbase2.drop.sql +1 -0
  151. data/test/fixtures/db_definitions/frontbase2.sql +4 -0
  152. data/test/fixtures/db_definitions/mysql.drop.sql +32 -0
  153. data/test/fixtures/db_definitions/mysql.sql +234 -0
  154. data/test/fixtures/db_definitions/mysql2.drop.sql +2 -0
  155. data/test/fixtures/db_definitions/mysql2.sql +5 -0
  156. data/test/fixtures/db_definitions/openbase.drop.sql +2 -0
  157. data/test/fixtures/db_definitions/openbase.sql +302 -0
  158. data/test/fixtures/db_definitions/openbase2.drop.sql +2 -0
  159. data/test/fixtures/db_definitions/openbase2.sql +7 -0
  160. data/test/fixtures/db_definitions/oracle.drop.sql +65 -0
  161. data/test/fixtures/db_definitions/oracle.sql +325 -0
  162. data/test/fixtures/db_definitions/oracle2.drop.sql +2 -0
  163. data/test/fixtures/db_definitions/oracle2.sql +6 -0
  164. data/test/fixtures/db_definitions/postgresql.drop.sql +37 -0
  165. data/test/fixtures/db_definitions/postgresql.sql +263 -0
  166. data/test/fixtures/db_definitions/postgresql2.drop.sql +2 -0
  167. data/test/fixtures/db_definitions/postgresql2.sql +5 -0
  168. data/test/fixtures/db_definitions/schema.rb +60 -0
  169. data/test/fixtures/db_definitions/sqlite.drop.sql +32 -0
  170. data/test/fixtures/db_definitions/sqlite.sql +215 -0
  171. data/test/fixtures/db_definitions/sqlite2.drop.sql +2 -0
  172. data/test/fixtures/db_definitions/sqlite2.sql +5 -0
  173. data/test/fixtures/db_definitions/sqlserver.drop.sql +34 -0
  174. data/test/fixtures/db_definitions/sqlserver.sql +243 -0
  175. data/test/fixtures/db_definitions/sqlserver2.drop.sql +2 -0
  176. data/test/fixtures/db_definitions/sqlserver2.sql +5 -0
  177. data/test/fixtures/db_definitions/sybase.drop.sql +34 -0
  178. data/test/fixtures/db_definitions/sybase.sql +218 -0
  179. data/test/fixtures/db_definitions/sybase2.drop.sql +4 -0
  180. data/test/fixtures/db_definitions/sybase2.sql +5 -0
  181. data/test/fixtures/default.rb +2 -0
  182. data/test/fixtures/developer.rb +52 -0
  183. data/test/fixtures/developers.yml +21 -0
  184. data/test/fixtures/developers_projects.yml +17 -0
  185. data/test/fixtures/developers_projects/david_action_controller +3 -0
  186. data/test/fixtures/developers_projects/david_active_record +3 -0
  187. data/test/fixtures/developers_projects/jamis_active_record +2 -0
  188. data/test/fixtures/edge.rb +5 -0
  189. data/test/fixtures/edges.yml +6 -0
  190. data/test/fixtures/entrant.rb +3 -0
  191. data/test/fixtures/entrants.yml +14 -0
  192. data/test/fixtures/fk_test_has_fk.yml +3 -0
  193. data/test/fixtures/fk_test_has_pk.yml +2 -0
  194. data/test/fixtures/flowers.jpg +0 -0
  195. data/test/fixtures/funny_jokes.yml +10 -0
  196. data/test/fixtures/joke.rb +6 -0
  197. data/test/fixtures/keyboard.rb +3 -0
  198. data/test/fixtures/legacy_thing.rb +3 -0
  199. data/test/fixtures/legacy_things.yml +3 -0
  200. data/test/fixtures/migrations/1_people_have_last_names.rb +9 -0
  201. data/test/fixtures/migrations/2_we_need_reminders.rb +12 -0
  202. data/test/fixtures/migrations/3_innocent_jointable.rb +12 -0
  203. data/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb +15 -0
  204. data/test/fixtures/migrations_with_duplicate/1_people_have_last_names.rb +9 -0
  205. data/test/fixtures/migrations_with_duplicate/2_we_need_reminders.rb +12 -0
  206. data/test/fixtures/migrations_with_duplicate/3_foo.rb +7 -0
  207. data/test/fixtures/migrations_with_duplicate/3_innocent_jointable.rb +12 -0
  208. data/test/fixtures/migrations_with_missing_versions/1000_people_have_middle_names.rb +9 -0
  209. data/test/fixtures/migrations_with_missing_versions/1_people_have_last_names.rb +9 -0
  210. data/test/fixtures/migrations_with_missing_versions/3_we_need_reminders.rb +12 -0
  211. data/test/fixtures/migrations_with_missing_versions/4_innocent_jointable.rb +12 -0
  212. data/test/fixtures/mixed_case_monkey.rb +3 -0
  213. data/test/fixtures/mixed_case_monkeys.yml +6 -0
  214. data/test/fixtures/mixin.rb +63 -0
  215. data/test/fixtures/mixins.yml +127 -0
  216. data/test/fixtures/movie.rb +5 -0
  217. data/test/fixtures/movies.yml +7 -0
  218. data/test/fixtures/naked/csv/accounts.csv +1 -0
  219. data/test/fixtures/naked/yml/accounts.yml +1 -0
  220. data/test/fixtures/naked/yml/companies.yml +1 -0
  221. data/test/fixtures/naked/yml/courses.yml +1 -0
  222. data/test/fixtures/order.rb +4 -0
  223. data/test/fixtures/people.yml +3 -0
  224. data/test/fixtures/person.rb +4 -0
  225. data/test/fixtures/post.rb +58 -0
  226. data/test/fixtures/posts.yml +48 -0
  227. data/test/fixtures/project.rb +27 -0
  228. data/test/fixtures/projects.yml +7 -0
  229. data/test/fixtures/reader.rb +4 -0
  230. data/test/fixtures/readers.yml +4 -0
  231. data/test/fixtures/reply.rb +37 -0
  232. data/test/fixtures/subject.rb +4 -0
  233. data/test/fixtures/subscriber.rb +6 -0
  234. data/test/fixtures/subscribers/first +2 -0
  235. data/test/fixtures/subscribers/second +2 -0
  236. data/test/fixtures/tag.rb +7 -0
  237. data/test/fixtures/tagging.rb +6 -0
  238. data/test/fixtures/taggings.yml +18 -0
  239. data/test/fixtures/tags.yml +7 -0
  240. data/test/fixtures/task.rb +3 -0
  241. data/test/fixtures/tasks.yml +7 -0
  242. data/test/fixtures/topic.rb +25 -0
  243. data/test/fixtures/topics.yml +22 -0
  244. data/test/fixtures/vertex.rb +9 -0
  245. data/test/fixtures/vertices.yml +4 -0
  246. data/test/fixtures_test.rb +401 -0
  247. data/test/inheritance_test.rb +205 -0
  248. data/test/lifecycle_test.rb +137 -0
  249. data/test/locking_test.rb +190 -0
  250. data/test/method_scoping_test.rb +416 -0
  251. data/test/migration_test.rb +768 -0
  252. data/test/migration_test_firebird.rb +124 -0
  253. data/test/mixin_nested_set_test.rb +196 -0
  254. data/test/mixin_test.rb +550 -0
  255. data/test/modules_test.rb +34 -0
  256. data/test/multiple_db_test.rb +60 -0
  257. data/test/pk_test.rb +104 -0
  258. data/test/readonly_test.rb +107 -0
  259. data/test/reflection_test.rb +159 -0
  260. data/test/schema_authorization_test_postgresql.rb +75 -0
  261. data/test/schema_dumper_test.rb +96 -0
  262. data/test/schema_test_postgresql.rb +64 -0
  263. data/test/synonym_test_oracle.rb +17 -0
  264. data/test/table_name_test_sqlserver.rb +23 -0
  265. data/test/threaded_connections_test.rb +48 -0
  266. data/test/transactions_test.rb +230 -0
  267. data/test/unconnected_test.rb +32 -0
  268. data/test/validations_test.rb +1097 -0
  269. data/test/xml_serialization_test.rb +125 -0
  270. metadata +365 -0
@@ -0,0 +1,263 @@
1
+ CREATE SEQUENCE public.accounts_id_seq START 100;
2
+
3
+ CREATE TABLE accounts (
4
+ id integer DEFAULT nextval('public.accounts_id_seq'),
5
+ firm_id integer,
6
+ credit_limit integer,
7
+ PRIMARY KEY (id)
8
+ );
9
+
10
+ CREATE TABLE funny_jokes (
11
+ id serial,
12
+ name character varying(50)
13
+ );
14
+
15
+ CREATE SEQUENCE companies_nonstd_seq START 101;
16
+
17
+ CREATE TABLE companies (
18
+ id integer DEFAULT nextval('companies_nonstd_seq'),
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
+
28
+ CREATE TABLE developers_projects (
29
+ developer_id integer NOT NULL,
30
+ project_id integer NOT NULL,
31
+ joined_on date,
32
+ access_level integer default 1
33
+ );
34
+
35
+ CREATE TABLE developers (
36
+ id serial,
37
+ name character varying(100),
38
+ salary integer DEFAULT 70000,
39
+ created_at timestamp,
40
+ updated_at timestamp,
41
+ PRIMARY KEY (id)
42
+ );
43
+ SELECT setval('developers_id_seq', 100);
44
+
45
+ CREATE TABLE projects (
46
+ id serial,
47
+ name character varying(100),
48
+ type varchar(255),
49
+ PRIMARY KEY (id)
50
+ );
51
+ SELECT setval('projects_id_seq', 100);
52
+
53
+ CREATE TABLE topics (
54
+ id serial,
55
+ title character varying(255),
56
+ author_name character varying(255),
57
+ author_email_address character varying(255),
58
+ written_on timestamp without time zone,
59
+ bonus_time time,
60
+ last_read date,
61
+ content text,
62
+ approved boolean default true,
63
+ replies_count integer default 0,
64
+ parent_id integer,
65
+ "type" character varying(50),
66
+ PRIMARY KEY (id)
67
+ );
68
+ SELECT setval('topics_id_seq', 100);
69
+
70
+ CREATE TABLE customers (
71
+ id serial,
72
+ name character varying,
73
+ balance integer default 0,
74
+ address_street character varying,
75
+ address_city character varying,
76
+ address_country character varying,
77
+ gps_location character varying,
78
+ PRIMARY KEY (id)
79
+ );
80
+ SELECT setval('customers_id_seq', 100);
81
+
82
+ CREATE TABLE orders (
83
+ id serial,
84
+ name character varying,
85
+ billing_customer_id integer,
86
+ shipping_customer_id integer,
87
+ PRIMARY KEY (id)
88
+ );
89
+ SELECT setval('orders_id_seq', 100);
90
+
91
+ CREATE TABLE movies (
92
+ movieid serial,
93
+ name text,
94
+ PRIMARY KEY (movieid)
95
+ );
96
+
97
+ CREATE TABLE subscribers (
98
+ nick text NOT NULL,
99
+ name text,
100
+ PRIMARY KEY (nick)
101
+ );
102
+
103
+ CREATE TABLE booleantests (
104
+ id serial,
105
+ value boolean,
106
+ PRIMARY KEY (id)
107
+ );
108
+
109
+ CREATE TABLE defaults (
110
+ id serial,
111
+ modified_date date default CURRENT_DATE,
112
+ modified_date_function date default now(),
113
+ fixed_date date default '2004-01-01',
114
+ modified_time timestamp default CURRENT_TIMESTAMP,
115
+ modified_time_function timestamp default now(),
116
+ fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
117
+ char1 char(1) default 'Y',
118
+ char2 character varying(50) default 'a varchar field',
119
+ char3 text default 'a text field',
120
+ positive_integer integer default 1,
121
+ negative_integer integer default -1,
122
+ decimal_number decimal(3,2) default 2.78
123
+ );
124
+
125
+ CREATE TABLE auto_id_tests (
126
+ auto_id serial,
127
+ value integer,
128
+ PRIMARY KEY (auto_id)
129
+ );
130
+
131
+ CREATE TABLE entrants (
132
+ id serial,
133
+ name text not null,
134
+ course_id integer not null
135
+ );
136
+
137
+ CREATE TABLE colnametests (
138
+ id serial,
139
+ "references" integer NOT NULL
140
+ );
141
+
142
+ CREATE TABLE mixins (
143
+ id serial,
144
+ parent_id integer,
145
+ type character varying,
146
+ pos integer,
147
+ lft integer,
148
+ rgt integer,
149
+ root_id integer,
150
+ created_at timestamp,
151
+ updated_at timestamp,
152
+ PRIMARY KEY (id)
153
+ );
154
+
155
+ CREATE TABLE people (
156
+ id serial,
157
+ first_name text,
158
+ lock_version integer default 0,
159
+ PRIMARY KEY (id)
160
+ );
161
+
162
+ CREATE TABLE readers (
163
+ id serial,
164
+ post_id integer NOT NULL,
165
+ person_id integer NOT NULL,
166
+ primary key (id)
167
+ );
168
+
169
+ CREATE TABLE binaries (
170
+ id serial ,
171
+ data bytea,
172
+ PRIMARY KEY (id)
173
+ );
174
+
175
+ CREATE TABLE computers (
176
+ id serial,
177
+ developer integer NOT NULL,
178
+ "extendedWarranty" integer NOT NULL
179
+ );
180
+
181
+ CREATE TABLE posts (
182
+ id serial,
183
+ author_id integer,
184
+ title varchar(255),
185
+ type varchar(255),
186
+ body text
187
+ );
188
+
189
+ CREATE TABLE comments (
190
+ id serial,
191
+ post_id integer,
192
+ type varchar(255),
193
+ body text
194
+ );
195
+
196
+ CREATE TABLE authors (
197
+ id serial,
198
+ name varchar(255) default NULL
199
+ );
200
+
201
+ CREATE TABLE tasks (
202
+ id serial,
203
+ starting timestamp,
204
+ ending timestamp,
205
+ PRIMARY KEY (id)
206
+ );
207
+
208
+ CREATE TABLE categories (
209
+ id serial,
210
+ name varchar(255),
211
+ type varchar(255)
212
+ );
213
+
214
+ CREATE TABLE categories_posts (
215
+ category_id integer NOT NULL,
216
+ post_id integer NOT NULL
217
+ );
218
+
219
+ CREATE TABLE fk_test_has_pk (
220
+ id INTEGER NOT NULL PRIMARY KEY
221
+ );
222
+
223
+ CREATE TABLE fk_test_has_fk (
224
+ id INTEGER NOT NULL PRIMARY KEY,
225
+ fk_id INTEGER NOT NULL REFERENCES fk_test_has_fk(id)
226
+ );
227
+
228
+ CREATE TABLE geometrics (
229
+ id serial primary key,
230
+ a_point point,
231
+ -- a_line line, (the line type is currently not implemented in postgresql)
232
+ a_line_segment lseg,
233
+ a_box box,
234
+ a_path path,
235
+ a_polygon polygon,
236
+ a_circle circle
237
+ );
238
+
239
+ CREATE TABLE keyboards (
240
+ key_number serial primary key,
241
+ "name" character varying(50)
242
+ );
243
+
244
+ --Altered lock_version column name.
245
+ CREATE TABLE legacy_things (
246
+ id serial primary key,
247
+ tps_report_number integer,
248
+ version integer default 0
249
+ );
250
+
251
+ CREATE TABLE numeric_data (
252
+ id serial primary key,
253
+ bank_balance decimal(10,2),
254
+ big_bank_balance decimal(15,2),
255
+ world_population decimal(10),
256
+ my_house_population decimal(2),
257
+ decimal_number_with_default decimal(3,2) default 2.78
258
+ );
259
+
260
+ CREATE TABLE mixed_case_monkeys (
261
+ "monkeyID" INTEGER PRIMARY KEY,
262
+ "fleaCount" INTEGER
263
+ );
@@ -0,0 +1,2 @@
1
+ DROP TABLE courses;
2
+
@@ -0,0 +1,5 @@
1
+ CREATE TABLE courses (
2
+ id serial,
3
+ name text
4
+ );
5
+
@@ -0,0 +1,60 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ # For Firebird, set the sequence values 10000 when create_table is called;
4
+ # this prevents primary key collisions between "normally" created records
5
+ # and fixture-based (YAML) records.
6
+ if adapter_name == "Firebird"
7
+ def create_table(*args, &block)
8
+ ActiveRecord::Base.connection.create_table(*args, &block)
9
+ ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
10
+ end
11
+ end
12
+
13
+ create_table :taggings, :force => true do |t|
14
+ t.column :tag_id, :integer
15
+ t.column :super_tag_id, :integer
16
+ t.column :taggable_type, :string
17
+ t.column :taggable_id, :integer
18
+ end
19
+
20
+ create_table :tags, :force => true do |t|
21
+ t.column :name, :string
22
+ t.column :taggings_count, :integer, :default => 0
23
+ end
24
+
25
+ create_table :categorizations, :force => true do |t|
26
+ t.column :category_id, :integer
27
+ t.column :post_id, :integer
28
+ t.column :author_id, :integer
29
+ end
30
+
31
+ add_column :posts, :taggings_count, :integer, :default => 0
32
+ add_column :authors, :author_address_id, :integer
33
+
34
+ create_table :author_addresses, :force => true do |t|
35
+ t.column :author_address_id, :integer
36
+ end
37
+
38
+ create_table :author_favorites, :force => true do |t|
39
+ t.column :author_id, :integer
40
+ t.column :favorite_author_id, :integer
41
+ end
42
+
43
+ create_table :vertices, :force => true do |t|
44
+ t.column :label, :string
45
+ end
46
+
47
+ create_table :edges, :force => true do |t|
48
+ t.column :source_id, :integer, :null => false
49
+ t.column :sink_id, :integer, :null => false
50
+ end
51
+ add_index :edges, [:source_id, :sink_id], :unique => true, :name => 'unique_edge_index'
52
+
53
+ create_table :lock_without_defaults, :force => true do |t|
54
+ t.column :lock_version, :integer
55
+ end
56
+
57
+ create_table :lock_without_defaults_cust, :force => true do |t|
58
+ t.column :custom_lock_version, :integer
59
+ end
60
+ end
@@ -0,0 +1,32 @@
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;
@@ -0,0 +1,215 @@
1
+ CREATE TABLE 'accounts' (
2
+ 'id' INTEGER PRIMARY KEY NOT NULL,
3
+ 'firm_id' INTEGER DEFAULT NULL,
4
+ 'credit_limit' INTEGER DEFAULT NULL
5
+ );
6
+
7
+ CREATE TABLE 'funny_jokes' (
8
+ 'id' INTEGER PRIMARY KEY NOT NULL,
9
+ 'name' TEXT DEFAULT NULL
10
+ );
11
+
12
+ CREATE TABLE 'companies' (
13
+ 'id' INTEGER PRIMARY KEY NOT NULL,
14
+ 'type' VARCHAR(255) DEFAULT NULL,
15
+ 'ruby_type' VARCHAR(255) DEFAULT NULL,
16
+ 'firm_id' INTEGER DEFAULT NULL,
17
+ 'name' TEXT DEFAULT NULL,
18
+ 'client_of' INTEGER DEFAULT NULL,
19
+ 'rating' INTEGER DEFAULT 1
20
+ );
21
+
22
+
23
+ CREATE TABLE 'topics' (
24
+ 'id' INTEGER PRIMARY KEY NOT NULL,
25
+ 'title' VARCHAR(255) DEFAULT NULL,
26
+ 'author_name' VARCHAR(255) DEFAULT NULL,
27
+ 'author_email_address' VARCHAR(255) DEFAULT NULL,
28
+ 'written_on' DATETIME DEFAULT NULL,
29
+ 'bonus_time' TIME DEFAULT NULL,
30
+ 'last_read' DATE DEFAULT NULL,
31
+ 'content' TEXT,
32
+ 'approved' boolean DEFAULT 't',
33
+ 'replies_count' INTEGER DEFAULT 0,
34
+ 'parent_id' INTEGER DEFAULT NULL,
35
+ 'type' VARCHAR(255) DEFAULT NULL
36
+ );
37
+
38
+ CREATE TABLE 'developers' (
39
+ 'id' INTEGER PRIMARY KEY NOT NULL,
40
+ 'name' TEXT DEFAULT NULL,
41
+ 'salary' INTEGER DEFAULT 70000,
42
+ 'created_at' DATETIME DEFAULT NULL,
43
+ 'updated_at' DATETIME DEFAULT NULL
44
+ );
45
+
46
+ CREATE TABLE 'projects' (
47
+ 'id' INTEGER PRIMARY KEY NOT NULL,
48
+ 'name' TEXT DEFAULT NULL,
49
+ 'type' VARCHAR(255) DEFAULT NULL
50
+ );
51
+
52
+ CREATE TABLE 'developers_projects' (
53
+ 'developer_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
65
+ );
66
+
67
+ CREATE TABLE 'customers' (
68
+ 'id' INTEGER PRIMARY KEY NOT NULL,
69
+ 'name' VARCHAR(255) DEFAULT NULL,
70
+ 'balance' INTEGER DEFAULT 0,
71
+ 'address_street' TEXT DEFAULT NULL,
72
+ 'address_city' TEXT DEFAULT NULL,
73
+ 'address_country' TEXT DEFAULT NULL,
74
+ 'gps_location' TEXT DEFAULT NULL
75
+ );
76
+
77
+ CREATE TABLE 'movies' (
78
+ 'movieid' INTEGER PRIMARY KEY NOT NULL,
79
+ 'name' VARCHAR(255) DEFAULT NULL
80
+ );
81
+
82
+ CREATE TABLE subscribers (
83
+ 'nick' VARCHAR(255) PRIMARY KEY NOT NULL,
84
+ 'name' VARCHAR(255) DEFAULT NULL
85
+ );
86
+
87
+ CREATE TABLE 'booleantests' (
88
+ 'id' INTEGER PRIMARY KEY NOT NULL,
89
+ 'value' INTEGER DEFAULT NULL
90
+ );
91
+
92
+ CREATE TABLE 'auto_id_tests' (
93
+ 'auto_id' INTEGER PRIMARY KEY NOT NULL,
94
+ 'value' INTEGER DEFAULT NULL
95
+ );
96
+
97
+ CREATE TABLE 'entrants' (
98
+ 'id' INTEGER NOT NULL PRIMARY KEY,
99
+ 'name' VARCHAR(255) NOT NULL,
100
+ 'course_id' INTEGER NOT NULL
101
+ );
102
+
103
+ CREATE TABLE 'colnametests' (
104
+ 'id' INTEGER NOT NULL PRIMARY KEY,
105
+ 'references' INTEGER NOT NULL
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
+ );