activerecord 1.13.2 → 1.14.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 (144) hide show
  1. data/CHANGELOG +452 -10
  2. data/RUNNING_UNIT_TESTS +1 -1
  3. data/lib/active_record.rb +5 -2
  4. data/lib/active_record/acts/list.rb +1 -1
  5. data/lib/active_record/acts/tree.rb +29 -25
  6. data/lib/active_record/aggregations.rb +3 -2
  7. data/lib/active_record/associations.rb +783 -337
  8. data/lib/active_record/associations/association_collection.rb +7 -12
  9. data/lib/active_record/associations/association_proxy.rb +62 -24
  10. data/lib/active_record/associations/belongs_to_association.rb +27 -46
  11. data/lib/active_record/associations/belongs_to_polymorphic_association.rb +50 -0
  12. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +38 -38
  13. data/lib/active_record/associations/has_many_association.rb +61 -56
  14. data/lib/active_record/associations/has_many_through_association.rb +144 -0
  15. data/lib/active_record/associations/has_one_association.rb +22 -16
  16. data/lib/active_record/base.rb +482 -182
  17. data/lib/active_record/calculations.rb +225 -0
  18. data/lib/active_record/callbacks.rb +7 -7
  19. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +162 -47
  20. data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
  21. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +2 -1
  22. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +21 -1
  23. data/lib/active_record/connection_adapters/abstract_adapter.rb +34 -2
  24. data/lib/active_record/connection_adapters/db2_adapter.rb +107 -61
  25. data/lib/active_record/connection_adapters/mysql_adapter.rb +29 -6
  26. data/lib/active_record/connection_adapters/openbase_adapter.rb +349 -0
  27. data/lib/active_record/connection_adapters/{oci_adapter.rb → oracle_adapter.rb} +125 -59
  28. data/lib/active_record/connection_adapters/postgresql_adapter.rb +24 -21
  29. data/lib/active_record/connection_adapters/sqlite_adapter.rb +47 -8
  30. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +36 -16
  31. data/lib/active_record/connection_adapters/sybase_adapter.rb +684 -0
  32. data/lib/active_record/fixtures.rb +42 -17
  33. data/lib/active_record/locking.rb +36 -15
  34. data/lib/active_record/migration.rb +111 -8
  35. data/lib/active_record/observer.rb +25 -1
  36. data/lib/active_record/reflection.rb +103 -41
  37. data/lib/active_record/schema.rb +2 -2
  38. data/lib/active_record/schema_dumper.rb +55 -18
  39. data/lib/active_record/timestamp.rb +6 -6
  40. data/lib/active_record/validations.rb +65 -40
  41. data/lib/active_record/vendor/db2.rb +10 -5
  42. data/lib/active_record/vendor/simple.rb +693 -702
  43. data/lib/active_record/version.rb +2 -2
  44. data/rakefile +4 -4
  45. data/test/aaa_create_tables_test.rb +25 -6
  46. data/test/abstract_unit.rb +39 -1
  47. data/test/adapter_test.rb +31 -4
  48. data/test/associations_cascaded_eager_loading_test.rb +106 -0
  49. data/test/associations_go_eager_test.rb +85 -16
  50. data/test/associations_join_model_test.rb +338 -0
  51. data/test/associations_test.rb +129 -50
  52. data/test/base_test.rb +204 -49
  53. data/test/binary_test.rb +1 -1
  54. data/test/calculations_test.rb +169 -0
  55. data/test/callbacks_test.rb +5 -23
  56. data/test/class_inheritable_attributes_test.rb +1 -1
  57. data/test/column_alias_test.rb +1 -1
  58. data/test/connections/native_mysql/connection.rb +1 -0
  59. data/test/connections/native_openbase/connection.rb +22 -0
  60. data/test/connections/{native_oci → native_oracle}/connection.rb +7 -9
  61. data/test/connections/native_sqlite/connection.rb +1 -1
  62. data/test/connections/native_sqlite3/connection.rb +1 -0
  63. data/test/connections/native_sqlite3/in_memory_connection.rb +1 -0
  64. data/test/connections/native_sybase/connection.rb +24 -0
  65. data/test/defaults_test.rb +18 -0
  66. data/test/deprecated_associations_test.rb +2 -2
  67. data/test/deprecated_finder_test.rb +0 -6
  68. data/test/finder_test.rb +26 -23
  69. data/test/fixtures/accounts.yml +10 -0
  70. data/test/fixtures/author.rb +31 -6
  71. data/test/fixtures/author_favorites.yml +4 -0
  72. data/test/fixtures/categories/special_categories.yml +9 -0
  73. data/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
  74. data/test/fixtures/categories_posts.yml +4 -0
  75. data/test/fixtures/categorization.rb +5 -0
  76. data/test/fixtures/categorizations.yml +11 -0
  77. data/test/fixtures/category.rb +6 -0
  78. data/test/fixtures/company.rb +17 -5
  79. data/test/fixtures/company_in_module.rb +19 -5
  80. data/test/fixtures/db_definitions/db2.drop.sql +3 -0
  81. data/test/fixtures/db_definitions/db2.sql +121 -100
  82. data/test/fixtures/db_definitions/db22.sql +2 -2
  83. data/test/fixtures/db_definitions/firebird.drop.sql +4 -0
  84. data/test/fixtures/db_definitions/firebird.sql +26 -0
  85. data/test/fixtures/db_definitions/mysql.drop.sql +3 -0
  86. data/test/fixtures/db_definitions/mysql.sql +21 -1
  87. data/test/fixtures/db_definitions/openbase.drop.sql +2 -0
  88. data/test/fixtures/db_definitions/openbase.sql +282 -0
  89. data/test/fixtures/db_definitions/openbase2.drop.sql +2 -0
  90. data/test/fixtures/db_definitions/openbase2.sql +7 -0
  91. data/test/fixtures/db_definitions/{oci.drop.sql → oracle.drop.sql} +6 -0
  92. data/test/fixtures/db_definitions/{oci.sql → oracle.sql} +25 -4
  93. data/test/fixtures/db_definitions/{oci2.drop.sql → oracle2.drop.sql} +0 -0
  94. data/test/fixtures/db_definitions/{oci2.sql → oracle2.sql} +0 -0
  95. data/test/fixtures/db_definitions/postgresql.drop.sql +4 -0
  96. data/test/fixtures/db_definitions/postgresql.sql +22 -1
  97. data/test/fixtures/db_definitions/schema.rb +32 -0
  98. data/test/fixtures/db_definitions/sqlite.drop.sql +3 -0
  99. data/test/fixtures/db_definitions/sqlite.sql +18 -0
  100. data/test/fixtures/db_definitions/sqlserver.drop.sql +3 -0
  101. data/test/fixtures/db_definitions/sqlserver.sql +23 -3
  102. data/test/fixtures/db_definitions/sybase.drop.sql +31 -0
  103. data/test/fixtures/db_definitions/sybase.sql +204 -0
  104. data/test/fixtures/db_definitions/sybase2.drop.sql +4 -0
  105. data/test/fixtures/db_definitions/sybase2.sql +5 -0
  106. data/test/fixtures/developers.yml +6 -1
  107. data/test/fixtures/developers_projects.yml +4 -0
  108. data/test/fixtures/funny_jokes.yml +14 -0
  109. data/test/fixtures/joke.rb +6 -0
  110. data/test/fixtures/legacy_thing.rb +3 -0
  111. data/test/fixtures/legacy_things.yml +3 -0
  112. data/test/fixtures/mixin.rb +1 -1
  113. data/test/fixtures/person.rb +4 -1
  114. data/test/fixtures/post.rb +26 -1
  115. data/test/fixtures/project.rb +1 -0
  116. data/test/fixtures/reader.rb +4 -0
  117. data/test/fixtures/readers.yml +4 -0
  118. data/test/fixtures/reply.rb +2 -1
  119. data/test/fixtures/tag.rb +5 -0
  120. data/test/fixtures/tagging.rb +6 -0
  121. data/test/fixtures/taggings.yml +18 -0
  122. data/test/fixtures/tags.yml +7 -0
  123. data/test/fixtures/tasks.yml +2 -2
  124. data/test/fixtures/topic.rb +2 -2
  125. data/test/fixtures/topics.yml +1 -0
  126. data/test/fixtures_test.rb +47 -13
  127. data/test/inheritance_test.rb +2 -2
  128. data/test/locking_test.rb +15 -1
  129. data/test/method_scoping_test.rb +248 -13
  130. data/test/migration_test.rb +68 -11
  131. data/test/mixin_nested_set_test.rb +1 -1
  132. data/test/modules_test.rb +6 -1
  133. data/test/readonly_test.rb +1 -1
  134. data/test/reflection_test.rb +63 -9
  135. data/test/schema_dumper_test.rb +41 -0
  136. data/test/{synonym_test_oci.rb → synonym_test_oracle.rb} +1 -1
  137. data/test/threaded_connections_test.rb +10 -0
  138. data/test/unconnected_test.rb +12 -5
  139. data/test/validations_test.rb +197 -10
  140. metadata +295 -260
  141. data/test/fixtures/db_definitions/create_oracle_db.bat +0 -0
  142. data/test/fixtures/db_definitions/create_oracle_db.sh +0 -0
  143. data/test/fixtures/fixture_database.sqlite +0 -0
  144. data/test/fixtures/fixture_database_2.sqlite +0 -0
@@ -14,11 +14,17 @@ create table companies (
14
14
  --
15
15
  create sequence companies_nonstd_seq minvalue 10000;
16
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
+
17
24
  create table accounts (
18
25
  id integer not null,
19
26
  firm_id integer default null references companies initially deferred disable,
20
- credit_limit integer default null,
21
- primary key (id)
27
+ credit_limit integer default null
22
28
  );
23
29
  create sequence accounts_seq minvalue 10000;
24
30
 
@@ -187,6 +193,14 @@ create table people (
187
193
  );
188
194
  create sequence people_seq minvalue 10000;
189
195
 
196
+ create table readers (
197
+ id integer not null,
198
+ post_id integer not null,
199
+ person_id integer not null,
200
+ primary key (id)
201
+ );
202
+ create sequence readers_seq minvalue 10000;
203
+
190
204
  create table binaries (
191
205
  id integer not null,
192
206
  data blob null,
@@ -261,11 +275,18 @@ create table keyboards (
261
275
  );
262
276
  create sequence keyboards_seq minvalue 10000;
263
277
 
264
- create table test_oci_defaults (
278
+ create table test_oracle_defaults (
265
279
  id integer not null primary key,
266
280
  test_char char(1) default 'X' not null,
267
281
  test_string varchar2(20) default 'hello' not null,
268
282
  test_int integer default 3 not null
269
283
  );
270
- create sequence test_oci_defaults_seq minvalue 10000;
284
+ create sequence test_oracle_defaults_seq minvalue 10000;
271
285
 
286
+ --This table has an altered lock_version column name.
287
+ create table legacy_things (
288
+ id integer not null primary key,
289
+ tps_report_number integer default null,
290
+ version integer default 0
291
+ );
292
+ create sequence legacy_things_seq minvalue 10000;
@@ -1,4 +1,6 @@
1
+ DROP SEQUENCE accounts_id_seq;
1
2
  DROP TABLE accounts;
3
+ DROP TABLE funny_jokes;
2
4
  DROP TABLE companies;
3
5
  DROP SEQUENCE companies_nonstd_seq;
4
6
  DROP TABLE topics;
@@ -15,6 +17,7 @@ DROP TABLE entrants;
15
17
  DROP TABLE colnametests;
16
18
  DROP TABLE mixins;
17
19
  DROP TABLE people;
20
+ DROP TABLE readers;
18
21
  DROP TABLE binaries;
19
22
  DROP TABLE computers;
20
23
  DROP TABLE posts;
@@ -28,3 +31,4 @@ DROP TABLE fk_test_has_fk;
28
31
  DROP TABLE fk_test_has_pk;
29
32
  DROP TABLE geometrics;
30
33
  DROP TABLE keyboards;
34
+ DROP TABLE legacy_things;
@@ -7,6 +7,11 @@ CREATE TABLE accounts (
7
7
  PRIMARY KEY (id)
8
8
  );
9
9
 
10
+ CREATE TABLE funny_jokes (
11
+ id serial,
12
+ name character varying(50)
13
+ );
14
+
10
15
  CREATE SEQUENCE companies_nonstd_seq START 101;
11
16
 
12
17
  CREATE TABLE companies (
@@ -111,7 +116,9 @@ CREATE TABLE defaults (
111
116
  fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
112
117
  char1 char(1) default 'Y',
113
118
  char2 character varying(50) default 'a varchar field',
114
- char3 text default 'a text field'
119
+ char3 text default 'a text field',
120
+ positive_integer integer default 1,
121
+ negative_integer integer default -1
115
122
  );
116
123
 
117
124
  CREATE TABLE auto_id_tests (
@@ -151,6 +158,13 @@ CREATE TABLE people (
151
158
  PRIMARY KEY (id)
152
159
  );
153
160
 
161
+ CREATE TABLE readers (
162
+ id serial,
163
+ post_id integer NOT NULL,
164
+ person_id integer NOT NULL,
165
+ primary key (id)
166
+ );
167
+
154
168
  CREATE TABLE binaries (
155
169
  id serial ,
156
170
  data bytea,
@@ -225,3 +239,10 @@ CREATE TABLE keyboards (
225
239
  key_number serial primary key,
226
240
  "name" character varying(50)
227
241
  );
242
+
243
+ --Altered lock_version column name.
244
+ CREATE TABLE legacy_things (
245
+ id serial primary key,
246
+ tps_report_number integer,
247
+ version integer default 0
248
+ );
@@ -0,0 +1,32 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ create_table :taggings, :force => true do |t|
4
+ t.column :tag_id, :integer
5
+ t.column :super_tag_id, :integer
6
+ t.column :taggable_type, :string
7
+ t.column :taggable_id, :integer
8
+ end
9
+
10
+ create_table :tags, :force => true do |t|
11
+ t.column :name, :string
12
+ t.column :taggings_count, :integer, :default => 0
13
+ end
14
+
15
+ create_table :categorizations, :force => true do |t|
16
+ t.column :category_id, :integer
17
+ t.column :post_id, :integer
18
+ t.column :author_id, :integer
19
+ end
20
+
21
+ add_column :posts, :taggings_count, :integer, :default => 0
22
+ add_column :authors, :author_address_id, :integer
23
+
24
+ create_table :author_addresses, :force => true do |t|
25
+ t.column :author_address_id, :integer
26
+ end
27
+
28
+ create_table :author_favorites, :force => true do |t|
29
+ t.column :author_id, :integer
30
+ t.column :favorite_author_id, :integer
31
+ end
32
+ end
@@ -1,4 +1,5 @@
1
1
  DROP TABLE accounts;
2
+ DROP TABLE funny_jokes;
2
3
  DROP TABLE companies;
3
4
  DROP TABLE topics;
4
5
  DROP TABLE developers;
@@ -14,6 +15,7 @@ DROP TABLE entrants;
14
15
  DROP TABLE colnametests;
15
16
  DROP TABLE mixins;
16
17
  DROP TABLE people;
18
+ DROP TABLE readers;
17
19
  DROP TABLE binaries;
18
20
  DROP TABLE computers;
19
21
  DROP TABLE tasks;
@@ -25,3 +27,4 @@ DROP TABLE categories_posts;
25
27
  DROP TABLE fk_test_has_fk;
26
28
  DROP TABLE fk_test_has_pk;
27
29
  DROP TABLE keyboards;
30
+ DROP TABLE legacy_things;
@@ -4,6 +4,11 @@ CREATE TABLE 'accounts' (
4
4
  'credit_limit' INTEGER DEFAULT NULL
5
5
  );
6
6
 
7
+ CREATE TABLE 'funny_jokes' (
8
+ 'id' INTEGER PRIMARY KEY NOT NULL,
9
+ 'name' TEXT DEFAULT NULL
10
+ );
11
+
7
12
  CREATE TABLE 'companies' (
8
13
  'id' INTEGER PRIMARY KEY NOT NULL,
9
14
  'type' VARCHAR(255) DEFAULT NULL,
@@ -118,6 +123,12 @@ CREATE TABLE 'people' (
118
123
  'lock_version' INTEGER NOT NULL DEFAULT 0
119
124
  );
120
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
+
121
132
  CREATE TABLE 'binaries' (
122
133
  'id' INTEGER NOT NULL PRIMARY KEY,
123
134
  'data' BLOB DEFAULT NULL
@@ -181,3 +192,10 @@ CREATE TABLE 'keyboards' (
181
192
  'key_number' INTEGER PRIMARY KEY NOT NULL,
182
193
  'name' VARCHAR(255) DEFAULT NULL
183
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
+ )
@@ -1,4 +1,5 @@
1
1
  DROP TABLE accounts;
2
+ DROP TABLE funny_jokes;
2
3
  DROP TABLE companies;
3
4
  DROP TABLE topics;
4
5
  DROP TABLE developers;
@@ -14,6 +15,7 @@ DROP TABLE entrants;
14
15
  DROP TABLE colnametests;
15
16
  DROP TABLE mixins;
16
17
  DROP TABLE people;
18
+ DROP TABLE readers;
17
19
  DROP TABLE binaries;
18
20
  DROP TABLE computers;
19
21
  DROP TABLE posts;
@@ -25,3 +27,4 @@ DROP TABLE categories_posts;
25
27
  DROP TABLE fk_test_has_fk;
26
28
  DROP TABLE fk_test_has_pk;
27
29
  DROP TABLE keyboards;
30
+ DROP TABLE legacy_things;
@@ -4,6 +4,11 @@ CREATE TABLE accounts (
4
4
  credit_limit int default NULL
5
5
  );
6
6
 
7
+ CREATE TABLE funny_jokes (
8
+ id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
9
+ name varchar(50) default NULL
10
+ );
11
+
7
12
  CREATE TABLE companies (
8
13
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
9
14
  type varchar(50) default NULL,
@@ -23,7 +28,7 @@ CREATE TABLE topics (
23
28
  bonus_time datetime default NULL,
24
29
  last_read datetime default NULL,
25
30
  content varchar(255) default NULL,
26
- approved tinyint default 1,
31
+ approved bit default 1,
27
32
  replies_count int default 0,
28
33
  parent_id int default NULL,
29
34
  type varchar(50) default NULL
@@ -118,6 +123,13 @@ CREATE TABLE people (
118
123
  PRIMARY KEY (id)
119
124
  );
120
125
 
126
+ CREATE TABLE readers (
127
+ id int NOT NULL IDENTITY(1, 1),
128
+ post_id int NOT NULL,
129
+ person_id int NOT NULL,
130
+ primary key (id)
131
+ );
132
+
121
133
  CREATE TABLE binaries (
122
134
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
123
135
  data image NULL
@@ -134,14 +146,14 @@ CREATE TABLE posts (
134
146
  author_id int default NULL,
135
147
  title varchar(255) default NULL,
136
148
  type varchar(255) default NULL,
137
- body text default NULL
149
+ body varchar(4096) default NULL
138
150
  );
139
151
 
140
152
  CREATE TABLE comments (
141
153
  id int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
142
154
  post_id int default NULL,
143
155
  type varchar(255) default NULL,
144
- body text default NULL
156
+ body varchar(4096) default NULL
145
157
  );
146
158
 
147
159
  CREATE TABLE authors (
@@ -181,3 +193,11 @@ CREATE TABLE keyboards (
181
193
  key_number int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
182
194
  name varchar(50) default NULL
183
195
  );
196
+
197
+ --This table has an altered lock_version column name.
198
+ CREATE TABLE legacy_things (
199
+ id int NOT NULL IDENTITY(1, 1),
200
+ tps_report_number int default NULL,
201
+ version int default 0,
202
+ PRIMARY KEY (id)
203
+ );
@@ -0,0 +1,31 @@
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
+ go
@@ -0,0 +1,204 @@
1
+ CREATE TABLE accounts (
2
+ id numeric(9,0) IDENTITY PRIMARY KEY,
3
+ firm_id int NULL,
4
+ credit_limit int NULL
5
+ )
6
+
7
+ CREATE TABLE funny_jokes (
8
+ id numeric(9,0) IDENTITY PRIMARY KEY,
9
+ name varchar(50) NULL
10
+ )
11
+
12
+ CREATE TABLE companies (
13
+ id numeric(9,0) IDENTITY PRIMARY KEY,
14
+ type varchar(50) NULL,
15
+ ruby_type varchar(50) NULL,
16
+ firm_id int NULL,
17
+ name varchar(50) NULL,
18
+ client_of int NULL,
19
+ rating int default 1
20
+ )
21
+
22
+
23
+ CREATE TABLE topics (
24
+ id numeric(9,0) IDENTITY PRIMARY KEY,
25
+ title varchar(255) NULL,
26
+ author_name varchar(255) NULL,
27
+ author_email_address varchar(255) NULL,
28
+ written_on datetime NULL,
29
+ bonus_time time NULL,
30
+ last_read datetime NULL,
31
+ content varchar(255) NULL,
32
+ approved bit default 1,
33
+ replies_count int default 0,
34
+ parent_id int NULL,
35
+ type varchar(50) NULL
36
+ )
37
+
38
+ CREATE TABLE developers (
39
+ id numeric(9,0) IDENTITY PRIMARY KEY,
40
+ name varchar(100) NULL,
41
+ salary int default 70000,
42
+ created_at datetime NULL,
43
+ updated_at datetime NULL
44
+ )
45
+
46
+ CREATE TABLE projects (
47
+ id numeric(9,0) IDENTITY PRIMARY KEY,
48
+ name varchar(100) NULL,
49
+ type varchar(255) NULL
50
+ )
51
+
52
+ CREATE TABLE developers_projects (
53
+ developer_id int NOT NULL,
54
+ project_id int NOT NULL,
55
+ joined_on datetime NULL,
56
+ access_level smallint default 1
57
+ )
58
+
59
+ CREATE TABLE orders (
60
+ id numeric(9,0) IDENTITY PRIMARY KEY,
61
+ name varchar(100) NULL,
62
+ billing_customer_id int NULL,
63
+ shipping_customer_id int NULL
64
+ )
65
+
66
+ CREATE TABLE customers (
67
+ id numeric(9,0) IDENTITY PRIMARY KEY,
68
+ name varchar(100) NULL,
69
+ balance int default 0,
70
+ address_street varchar(100) NULL,
71
+ address_city varchar(100) NULL,
72
+ address_country varchar(100) NULL,
73
+ gps_location varchar(100) NULL
74
+ )
75
+
76
+ CREATE TABLE movies (
77
+ movieid numeric(9,0) IDENTITY PRIMARY KEY,
78
+ name varchar(100) NULL
79
+ )
80
+
81
+ CREATE TABLE subscribers (
82
+ nick varchar(100) PRIMARY KEY,
83
+ name varchar(100) NULL
84
+ )
85
+
86
+ CREATE TABLE booleantests (
87
+ id numeric(9,0) IDENTITY PRIMARY KEY,
88
+ value int NULL
89
+ )
90
+
91
+ CREATE TABLE auto_id_tests (
92
+ auto_id numeric(9,0) IDENTITY PRIMARY KEY,
93
+ value int NULL
94
+ )
95
+
96
+ CREATE TABLE entrants (
97
+ id numeric(9,0) IDENTITY PRIMARY KEY,
98
+ name varchar(255) NOT NULL,
99
+ course_id int NOT NULL
100
+ )
101
+
102
+ CREATE TABLE colnametests (
103
+ id numeric(9,0) IDENTITY PRIMARY KEY,
104
+ [references] int NOT NULL
105
+ )
106
+
107
+ CREATE TABLE mixins (
108
+ id numeric(9,0) IDENTITY PRIMARY KEY,
109
+ parent_id int NULL,
110
+ pos int NULL,
111
+ created_at datetime NULL,
112
+ updated_at datetime NULL,
113
+ lft int NULL,
114
+ rgt int NULL,
115
+ root_id int NULL,
116
+ type varchar(40) NULL
117
+ )
118
+
119
+ CREATE TABLE people (
120
+ id numeric(9,0) IDENTITY PRIMARY KEY,
121
+ first_name varchar(40) NOT NULL,
122
+ lock_version int DEFAULT 0
123
+ )
124
+
125
+ CREATE TABLE readers (
126
+ id numeric(9,0) IDENTITY PRIMARY KEY,
127
+ post_id int NOT NULL,
128
+ person_id int NOT NULL
129
+ )
130
+
131
+ CREATE TABLE binaries (
132
+ id numeric(9,0) IDENTITY PRIMARY KEY,
133
+ data image NULL
134
+ )
135
+
136
+ CREATE TABLE computers (
137
+ id numeric(9,0) IDENTITY PRIMARY KEY,
138
+ developer int NOT NULL,
139
+ extendedWarranty int NOT NULL
140
+ )
141
+
142
+ CREATE TABLE posts (
143
+ id numeric(9,0) IDENTITY PRIMARY KEY,
144
+ author_id int NULL,
145
+ title varchar(255) NOT NULL,
146
+ body varchar(2048) NOT NULL,
147
+ type varchar(255) NOT NULL
148
+ )
149
+
150
+ CREATE TABLE comments (
151
+ id numeric(9,0) IDENTITY PRIMARY KEY,
152
+ post_id int NOT NULL,
153
+ body varchar(2048) NOT NULL,
154
+ type varchar(255) NOT NULL
155
+ )
156
+
157
+ CREATE TABLE authors (
158
+ id numeric(9,0) IDENTITY PRIMARY KEY,
159
+ name varchar(255) NOT NULL
160
+ )
161
+
162
+ CREATE TABLE tasks (
163
+ id numeric(9,0) IDENTITY PRIMARY KEY,
164
+ starting datetime NULL,
165
+ ending datetime NULL
166
+ )
167
+
168
+ CREATE TABLE categories (
169
+ id numeric(9,0) IDENTITY PRIMARY KEY,
170
+ name varchar(255) NOT NULL,
171
+ type varchar(255) NOT NULL
172
+ )
173
+
174
+ CREATE TABLE categories_posts (
175
+ category_id int NOT NULL,
176
+ post_id int NOT NULL
177
+ )
178
+
179
+ CREATE TABLE fk_test_has_pk (
180
+ id numeric(9,0) IDENTITY PRIMARY KEY
181
+ )
182
+
183
+ CREATE TABLE fk_test_has_fk (
184
+ id numeric(9,0) PRIMARY KEY,
185
+ fk_id numeric(9,0) NOT NULL,
186
+
187
+ FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
188
+ )
189
+
190
+
191
+ CREATE TABLE keyboards (
192
+ key_number numeric(9,0) IDENTITY PRIMARY KEY,
193
+ name varchar(50) NULL
194
+ )
195
+
196
+ --This table has an altered lock_version column name.
197
+ CREATE TABLE legacy_things (
198
+ id numeric(9,0) IDENTITY PRIMARY KEY,
199
+ tps_report_number int default NULL,
200
+ version int default 0,
201
+ )
202
+
203
+ go
204
+