activerecord 1.10.1 → 1.11.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.
- data/CHANGELOG +187 -19
- data/RUNNING_UNIT_TESTS +11 -0
- data/lib/active_record.rb +3 -1
- data/lib/active_record/acts/list.rb +25 -14
- data/lib/active_record/acts/nested_set.rb +4 -4
- data/lib/active_record/acts/tree.rb +18 -1
- data/lib/active_record/associations.rb +90 -17
- data/lib/active_record/associations/association_collection.rb +44 -5
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +17 -4
- data/lib/active_record/associations/has_many_association.rb +13 -3
- data/lib/active_record/associations/has_one_association.rb +19 -0
- data/lib/active_record/base.rb +292 -268
- data/lib/active_record/callbacks.rb +14 -14
- data/lib/active_record/connection_adapters/abstract_adapter.rb +137 -75
- data/lib/active_record/connection_adapters/db2_adapter.rb +10 -8
- data/lib/active_record/connection_adapters/mysql_adapter.rb +91 -64
- data/lib/active_record/connection_adapters/oci_adapter.rb +6 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +113 -60
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +15 -12
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +159 -132
- data/lib/active_record/fixtures.rb +59 -12
- data/lib/active_record/locking.rb +10 -9
- data/lib/active_record/migration.rb +112 -5
- data/lib/active_record/query_cache.rb +64 -0
- data/lib/active_record/timestamp.rb +10 -8
- data/lib/active_record/validations.rb +121 -26
- data/rakefile +16 -10
- data/test/aaa_create_tables_test.rb +26 -48
- data/test/abstract_unit.rb +3 -0
- data/test/aggregations_test.rb +19 -19
- data/test/association_callbacks_test.rb +110 -0
- data/test/associations_go_eager_test.rb +48 -14
- data/test/associations_test.rb +344 -142
- data/test/base_test.rb +150 -31
- data/test/binary_test.rb +7 -0
- data/test/callbacks_test.rb +24 -5
- data/test/column_alias_test.rb +2 -2
- data/test/connections/native_sqlserver_odbc/connection.rb +26 -0
- data/test/deprecated_associations_test.rb +27 -28
- data/test/deprecated_finder_test.rb +8 -9
- data/test/finder_test.rb +52 -17
- data/test/fixtures/author.rb +39 -0
- data/test/fixtures/categories.yml +7 -0
- data/test/fixtures/categories_posts.yml +8 -0
- data/test/fixtures/category.rb +2 -0
- data/test/fixtures/comment.rb +3 -1
- data/test/fixtures/comments.yml +43 -1
- data/test/fixtures/companies.yml +14 -0
- data/test/fixtures/company.rb +1 -1
- data/test/fixtures/computers.yml +2 -1
- data/test/fixtures/db_definitions/db2.sql +7 -2
- data/test/fixtures/db_definitions/mysql.drop.sql +2 -0
- data/test/fixtures/db_definitions/mysql.sql +11 -6
- data/test/fixtures/db_definitions/oci.sql +7 -2
- data/test/fixtures/db_definitions/postgresql.drop.sql +3 -1
- data/test/fixtures/db_definitions/postgresql.sql +8 -5
- data/test/fixtures/db_definitions/sqlite.drop.sql +2 -0
- data/test/fixtures/db_definitions/sqlite.sql +9 -4
- data/test/fixtures/db_definitions/sqlserver.drop.sql +2 -0
- data/test/fixtures/db_definitions/sqlserver.sql +12 -7
- data/test/fixtures/developer.rb +8 -1
- data/test/fixtures/migrations/3_innocent_jointable.rb +12 -0
- data/test/fixtures/post.rb +8 -2
- data/test/fixtures/posts.yml +21 -0
- data/test/fixtures/project.rb +14 -1
- data/test/fixtures/subscriber.rb +3 -0
- data/test/fixtures_test.rb +14 -0
- data/test/inheritance_test.rb +30 -22
- data/test/lifecycle_test.rb +3 -4
- data/test/locking_test.rb +2 -4
- data/test/migration_test.rb +186 -0
- data/test/mixin_nested_set_test.rb +19 -19
- data/test/mixin_test.rb +88 -88
- data/test/modules_test.rb +5 -10
- data/test/multiple_db_test.rb +2 -0
- data/test/pk_test.rb +8 -12
- data/test/reflection_test.rb +8 -4
- data/test/schema_test_postgresql.rb +63 -0
- data/test/thread_safety_test.rb +4 -1
- data/test/transactions_test.rb +9 -2
- data/test/unconnected_test.rb +1 -0
- data/test/validations_test.rb +151 -8
- metadata +11 -5
- data/test/migration_mysql.rb +0 -104
@@ -11,7 +11,7 @@ class FinderTest < Test::Unit::TestCase
|
|
11
11
|
entrants = Entrant.find_all nil, "id ASC", 2
|
12
12
|
|
13
13
|
assert_equal(2, entrants.size)
|
14
|
-
assert_equal(
|
14
|
+
assert_equal(entrants(:first).name, entrants.first.name)
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_find_all_with_prepared_limit_and_offset
|
@@ -23,13 +23,13 @@ class FinderTest < Test::Unit::TestCase
|
|
23
23
|
entrants = Entrant.find_all nil, "id ASC", [2, 1]
|
24
24
|
|
25
25
|
assert_equal(2, entrants.size)
|
26
|
-
assert_equal(
|
26
|
+
assert_equal(entrants(:second).name, entrants.first.name)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_find_first
|
31
31
|
first = Topic.find_first "title = 'The First Topic'"
|
32
|
-
assert_equal(
|
32
|
+
assert_equal(topics(:first).title, first.title)
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_find_first_failing
|
@@ -112,7 +112,7 @@ class FinderTest < Test::Unit::TestCase
|
|
112
112
|
assert_equal first_five_developers, Developer.find_all(nil, 'id ASC', [5])
|
113
113
|
assert_equal no_developers, Developer.find_all(nil, 'id ASC', [0])
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
def test_find_all_with_limit_and_offset
|
117
117
|
first_three_developers = Developer.find_all nil, 'id ASC', [3, 0]
|
118
118
|
second_three_developers = Developer.find_all nil, 'id ASC', [3, 3]
|
@@ -128,14 +128,13 @@ class FinderTest < Test::Unit::TestCase
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_find_all_by_one_attribute_with_options
|
131
|
-
topics = Topic.find_all_by_content("Have a nice day",
|
132
|
-
assert
|
131
|
+
topics = Topic.find_all_by_content("Have a nice day", "id DESC")
|
132
|
+
assert topics(:first), topics.last
|
133
133
|
|
134
|
-
topics = Topic.find_all_by_content("Have a nice day",
|
135
|
-
assert
|
134
|
+
topics = Topic.find_all_by_content("Have a nice day", "id DESC")
|
135
|
+
assert topics(:first), topics.first
|
136
136
|
end
|
137
137
|
|
138
|
-
|
139
138
|
protected
|
140
139
|
def bind(statement, *vars)
|
141
140
|
if vars.first.is_a?(Hash)
|
data/test/finder_test.rb
CHANGED
@@ -8,7 +8,7 @@ class FinderTest < Test::Unit::TestCase
|
|
8
8
|
fixtures :companies, :topics, :entrants, :developers
|
9
9
|
|
10
10
|
def test_find
|
11
|
-
assert_equal(
|
11
|
+
assert_equal(topics(:first).title, Topic.find(1).title)
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_exists
|
@@ -25,7 +25,11 @@ class FinderTest < Test::Unit::TestCase
|
|
25
25
|
|
26
26
|
def test_find_by_ids
|
27
27
|
assert_equal(2, Topic.find(1, 2).length)
|
28
|
-
assert_equal(
|
28
|
+
assert_equal(topics(:second).title, Topic.find([ 2 ]).first.title)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_find_an_empty_array
|
32
|
+
assert_equal [], Topic.find([])
|
29
33
|
end
|
30
34
|
|
31
35
|
def test_find_by_ids_missing_one
|
@@ -38,19 +42,23 @@ class FinderTest < Test::Unit::TestCase
|
|
38
42
|
entrants = Entrant.find(:all, :order => "id ASC", :limit => 2)
|
39
43
|
|
40
44
|
assert_equal(2, entrants.size)
|
41
|
-
assert_equal(
|
45
|
+
assert_equal(entrants(:first).name, entrants.first.name)
|
42
46
|
end
|
43
47
|
|
44
48
|
def test_find_all_with_prepared_limit_and_offset
|
45
49
|
if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
|
46
50
|
if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
|
47
|
-
assert_raises(ArgumentError) { Entrant.
|
51
|
+
assert_raises(ArgumentError) { Entrant.find(:all, :order => 'id ASC', :limit => 2, :offset => 1) }
|
48
52
|
end
|
49
53
|
else
|
50
54
|
entrants = Entrant.find(:all, :order => "id ASC", :limit => 2, :offset => 1)
|
51
55
|
|
52
56
|
assert_equal(2, entrants.size)
|
53
|
-
assert_equal(
|
57
|
+
assert_equal(entrants(:second).name, entrants.first.name)
|
58
|
+
|
59
|
+
entrants = Entrant.find(:all, :order => "id ASC", :limit => 2, :offset => 2)
|
60
|
+
assert_equal(1, entrants.size)
|
61
|
+
assert_equal(entrants(:third).name, entrants.first.name)
|
54
62
|
end
|
55
63
|
end
|
56
64
|
|
@@ -58,19 +66,19 @@ class FinderTest < Test::Unit::TestCase
|
|
58
66
|
topics = Topic.find_by_sql "SELECT * FROM topics WHERE author_name = 'Mary'"
|
59
67
|
|
60
68
|
assert_equal(1, topics.size)
|
61
|
-
assert_equal(
|
69
|
+
assert_equal(topics(:second).title, topics.first.title)
|
62
70
|
end
|
63
71
|
|
64
72
|
def test_find_with_prepared_select_statement
|
65
73
|
topics = Topic.find_by_sql ["SELECT * FROM topics WHERE author_name = ?", "Mary"]
|
66
74
|
|
67
75
|
assert_equal(1, topics.size)
|
68
|
-
assert_equal(
|
76
|
+
assert_equal(topics(:second).title, topics.first.title)
|
69
77
|
end
|
70
78
|
|
71
79
|
def test_find_first
|
72
80
|
first = Topic.find(:first, :conditions => "title = 'The First Topic'")
|
73
|
-
assert_equal(
|
81
|
+
assert_equal(topics(:first).title, first.title)
|
74
82
|
end
|
75
83
|
|
76
84
|
def test_find_first_failing
|
@@ -156,12 +164,23 @@ class FinderTest < Test::Unit::TestCase
|
|
156
164
|
assert_raises(ActiveRecord::PreparedStatementInvalid) { bind ':a :a', :a => 1, :b => 2 } # ' ruby-mode
|
157
165
|
end
|
158
166
|
|
159
|
-
def
|
167
|
+
def test_bind_enumerable
|
160
168
|
assert_equal '1,2,3', bind('?', [1, 2, 3])
|
161
169
|
assert_equal %('a','b','c'), bind('?', %w(a b c))
|
162
170
|
|
163
171
|
assert_equal '1,2,3', bind(':a', :a => [1, 2, 3])
|
164
172
|
assert_equal %('a','b','c'), bind(':a', :a => %w(a b c)) # '
|
173
|
+
|
174
|
+
require 'set'
|
175
|
+
assert_equal '1,2,3', bind('?', Set.new([1, 2, 3]))
|
176
|
+
assert_equal %('a','b','c'), bind('?', Set.new(%w(a b c)))
|
177
|
+
|
178
|
+
assert_equal '1,2,3', bind(':a', :a => Set.new([1, 2, 3]))
|
179
|
+
assert_equal %('a','b','c'), bind(':a', :a => Set.new(%w(a b c))) # '
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_bind_string
|
183
|
+
assert_equal "''", bind('?', '')
|
165
184
|
end
|
166
185
|
|
167
186
|
def test_string_sanitation
|
@@ -182,7 +201,7 @@ class FinderTest < Test::Unit::TestCase
|
|
182
201
|
end
|
183
202
|
|
184
203
|
def test_find_by_one_attribute
|
185
|
-
assert_equal
|
204
|
+
assert_equal topics(:first), Topic.find_by_title("The First Topic")
|
186
205
|
assert_nil Topic.find_by_title("The First Topic!")
|
187
206
|
end
|
188
207
|
|
@@ -191,34 +210,38 @@ class FinderTest < Test::Unit::TestCase
|
|
191
210
|
end
|
192
211
|
|
193
212
|
def test_find_by_two_attributes
|
194
|
-
assert_equal
|
213
|
+
assert_equal topics(:first), Topic.find_by_title_and_author_name("The First Topic", "David")
|
195
214
|
assert_nil Topic.find_by_title_and_author_name("The First Topic", "Mary")
|
196
215
|
end
|
197
216
|
|
198
217
|
def test_find_all_by_one_attribute
|
199
218
|
topics = Topic.find_all_by_content("Have a nice day")
|
200
219
|
assert_equal 2, topics.size
|
201
|
-
assert topics.include?(
|
220
|
+
assert topics.include?(topics(:first))
|
202
221
|
|
203
222
|
assert_equal [], Topic.find_all_by_title("The First Topic!!")
|
204
223
|
end
|
205
224
|
|
206
225
|
def test_find_all_by_one_attribute_with_options
|
207
226
|
topics = Topic.find_all_by_content("Have a nice day", :order => "id DESC")
|
208
|
-
assert
|
227
|
+
assert topics(:first), topics.last
|
209
228
|
|
210
229
|
topics = Topic.find_all_by_content("Have a nice day", :order => "id")
|
211
|
-
assert
|
230
|
+
assert topics(:first), topics.first
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_find_all_by_array_attribute
|
234
|
+
assert_equal 2, Topic.find_all_by_title(["The First Topic", "The Second Topic's of the day"]).size
|
212
235
|
end
|
213
236
|
|
214
237
|
def test_find_all_by_boolean_attribute
|
215
238
|
topics = Topic.find_all_by_approved(false)
|
216
239
|
assert_equal 1, topics.size
|
217
|
-
assert topics.include?(
|
240
|
+
assert topics.include?(topics(:first))
|
218
241
|
|
219
242
|
topics = Topic.find_all_by_approved(true)
|
220
243
|
assert_equal 1, topics.size
|
221
|
-
assert topics.include?(
|
244
|
+
assert topics.include?(topics(:second))
|
222
245
|
end
|
223
246
|
|
224
247
|
def test_find_by_nil_attribute
|
@@ -257,7 +280,7 @@ class FinderTest < Test::Unit::TestCase
|
|
257
280
|
no_developers = Developer.find :all, :order => 'id ASC', :limit => 0
|
258
281
|
assert_equal 0, no_developers.length
|
259
282
|
end
|
260
|
-
|
283
|
+
|
261
284
|
def test_find_all_with_limit_and_offset
|
262
285
|
first_three_developers = Developer.find :all, :order => 'id ASC', :limit => 3, :offset => 0
|
263
286
|
second_three_developers = Developer.find :all, :order => 'id ASC', :limit => 3, :offset => 3
|
@@ -272,6 +295,18 @@ class FinderTest < Test::Unit::TestCase
|
|
272
295
|
assert_equal 'fixture_9', last_two_developers.first.name
|
273
296
|
end
|
274
297
|
|
298
|
+
def test_find_all_with_join
|
299
|
+
developers_on_project_one = Developer.find(
|
300
|
+
:all,
|
301
|
+
:joins => 'LEFT JOIN developers_projects ON developers.id = developers_projects.developer_id',
|
302
|
+
:conditions => 'project_id=1'
|
303
|
+
)
|
304
|
+
assert_equal 2, developers_on_project_one.length
|
305
|
+
developer_names = developers_on_project_one.map { |d| d.name }
|
306
|
+
assert developer_names.include?('David')
|
307
|
+
assert developer_names.include?('Jamis')
|
308
|
+
end
|
309
|
+
|
275
310
|
protected
|
276
311
|
def bind(statement, *vars)
|
277
312
|
if vars.first.is_a?(Hash)
|
data/test/fixtures/author.rb
CHANGED
@@ -1,3 +1,42 @@
|
|
1
1
|
class Author < ActiveRecord::Base
|
2
2
|
has_many :posts
|
3
|
+
has_many :posts_with_callbacks, :class_name => "Post", :before_add => :log_before_adding,
|
4
|
+
:after_add => :log_after_adding, :before_remove => :log_before_removing,
|
5
|
+
:after_remove => :log_after_removing
|
6
|
+
has_many :posts_with_proc_callbacks, :class_name => "Post",
|
7
|
+
:before_add => Proc.new {|o, r| o.post_log << "before_adding#{r.id}"},
|
8
|
+
:after_add => Proc.new {|o, r| o.post_log << "after_adding#{r.id}"},
|
9
|
+
:before_remove => Proc.new {|o, r| o.post_log << "before_removing#{r.id}"},
|
10
|
+
:after_remove => Proc.new {|o, r| o.post_log << "after_removing#{r.id}"}
|
11
|
+
has_many :posts_with_multiple_callbacks, :class_name => "Post",
|
12
|
+
:before_add => [:log_before_adding, Proc.new {|o, r| o.post_log << "before_adding_proc#{r.id}"}],
|
13
|
+
:after_add => [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id}"}]
|
14
|
+
has_many :unchangable_posts, :class_name => "Post", :before_add => :raise_exception, :after_add => :log_after_adding
|
15
|
+
|
16
|
+
attr_accessor :post_log
|
17
|
+
|
18
|
+
def after_initialize
|
19
|
+
@post_log = []
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def log_before_adding(object)
|
24
|
+
@post_log << "before_adding#{object.id}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def log_after_adding(object)
|
28
|
+
@post_log << "after_adding#{object.id}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def log_before_removing(object)
|
32
|
+
@post_log << "before_removing#{object.id}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def log_after_removing(object)
|
36
|
+
@post_log << "after_removing#{object.id}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def raise_exception(object)
|
40
|
+
raise Exception.new("You can't add a post")
|
41
|
+
end
|
3
42
|
end
|
data/test/fixtures/category.rb
CHANGED
data/test/fixtures/comment.rb
CHANGED
data/test/fixtures/comments.yml
CHANGED
@@ -14,4 +14,46 @@ does_it_hurt:
|
|
14
14
|
id: 3
|
15
15
|
post_id: 2
|
16
16
|
body: Don't think too hard
|
17
|
-
type: SpecialComment
|
17
|
+
type: SpecialComment
|
18
|
+
|
19
|
+
eager_sti_on_associations_comment:
|
20
|
+
id: 4
|
21
|
+
post_id: 4
|
22
|
+
body: Normal type
|
23
|
+
type: Comment
|
24
|
+
|
25
|
+
eager_sti_on_associations_vs_comment:
|
26
|
+
id: 5
|
27
|
+
post_id: 4
|
28
|
+
body: Very Special type
|
29
|
+
type: VerySpecialComment
|
30
|
+
|
31
|
+
eager_sti_on_associations_s_comment1:
|
32
|
+
id: 6
|
33
|
+
post_id: 4
|
34
|
+
body: Special type
|
35
|
+
type: SpecialComment
|
36
|
+
|
37
|
+
eager_sti_on_associations_s_comment2:
|
38
|
+
id: 7
|
39
|
+
post_id: 4
|
40
|
+
body: Special type 2
|
41
|
+
type: SpecialComment
|
42
|
+
|
43
|
+
eager_sti_on_associations_comment:
|
44
|
+
id: 8
|
45
|
+
post_id: 4
|
46
|
+
body: Normal type
|
47
|
+
type: Comment
|
48
|
+
|
49
|
+
check_eager_sti_on_associations:
|
50
|
+
id: 9
|
51
|
+
post_id: 5
|
52
|
+
body: Normal type
|
53
|
+
type: Comment
|
54
|
+
|
55
|
+
check_eager_sti_on_associations2:
|
56
|
+
id: 10
|
57
|
+
post_id: 5
|
58
|
+
body: Special Type
|
59
|
+
type: SpecialComment
|
data/test/fixtures/companies.yml
CHANGED
@@ -19,3 +19,17 @@ second_client:
|
|
19
19
|
client_of: 1
|
20
20
|
name: Microsoft
|
21
21
|
ruby_type: Client
|
22
|
+
|
23
|
+
another_firm:
|
24
|
+
id: 4
|
25
|
+
type: Firm
|
26
|
+
name: Flamboyant Software
|
27
|
+
ruby_type: Firm
|
28
|
+
|
29
|
+
another_client:
|
30
|
+
id: 5
|
31
|
+
type: Client
|
32
|
+
firm_id: 4
|
33
|
+
client_of: 4
|
34
|
+
name: Ex Nihilo
|
35
|
+
ruby_type: Client
|
data/test/fixtures/company.rb
CHANGED
@@ -21,7 +21,7 @@ class Firm < Company
|
|
21
21
|
:finder_sql => 'SELECT * FROM companies WHERE client_of = 1000',
|
22
22
|
:counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = 1000'
|
23
23
|
|
24
|
-
has_one :account, :dependent => true
|
24
|
+
has_one :account, :foreign_key => "firm_id", :dependent => true
|
25
25
|
end
|
26
26
|
|
27
27
|
class Client < Company
|
data/test/fixtures/computers.yml
CHANGED
@@ -36,12 +36,15 @@ CREATE TABLE developers (
|
|
36
36
|
id int generated by default as identity (start with +10000),
|
37
37
|
name varchar(100) default NULL,
|
38
38
|
salary int default 70000,
|
39
|
+
created_at timestamp default NULL,
|
40
|
+
updated_at timestamp default NULL,
|
39
41
|
PRIMARY KEY (id)
|
40
42
|
);
|
41
43
|
|
42
44
|
CREATE TABLE projects (
|
43
45
|
id int generated by default as identity (start with +10000),
|
44
46
|
name varchar(100) default NULL,
|
47
|
+
type varchar(255) default NULL,
|
45
48
|
PRIMARY KEY (id)
|
46
49
|
);
|
47
50
|
|
@@ -126,7 +129,8 @@ CREATE TABLE binaries (
|
|
126
129
|
|
127
130
|
CREATE TABLE computers (
|
128
131
|
id int generated by default as identity (start with +10000),
|
129
|
-
developer int NOT NULL
|
132
|
+
developer int NOT NULL,
|
133
|
+
extendedWarranty int NOT NULL
|
130
134
|
);
|
131
135
|
|
132
136
|
CREATE TABLE posts (
|
@@ -157,7 +161,8 @@ CREATE TABLE tasks (
|
|
157
161
|
|
158
162
|
CREATE TABLE categories (
|
159
163
|
id int generated by default as identity (start with +10000),
|
160
|
-
name varchar(255) NOT NULL
|
164
|
+
name varchar(255) NOT NULL,
|
165
|
+
type varchar(40) default NULL
|
161
166
|
);
|
162
167
|
|
163
168
|
CREATE TABLE categories_posts (
|
@@ -37,12 +37,15 @@ CREATE TABLE `developers` (
|
|
37
37
|
`id` int(11) NOT NULL auto_increment,
|
38
38
|
`name` varchar(100) default NULL,
|
39
39
|
`salary` int(11) default 70000,
|
40
|
+
`created_at` datetime default NULL,
|
41
|
+
`updated_at` datetime default NULL,
|
40
42
|
PRIMARY KEY (`id`)
|
41
43
|
) TYPE=InnoDB;
|
42
44
|
|
43
45
|
CREATE TABLE `projects` (
|
44
46
|
`id` int(11) NOT NULL auto_increment,
|
45
47
|
`name` varchar(100) default NULL,
|
48
|
+
`type` VARCHAR(255) NOT NULL,
|
46
49
|
PRIMARY KEY (`id`)
|
47
50
|
) TYPE=InnoDB;
|
48
51
|
|
@@ -126,7 +129,8 @@ CREATE TABLE `binaries` (
|
|
126
129
|
|
127
130
|
CREATE TABLE `computers` (
|
128
131
|
`id` INTEGER NOT NULL PRIMARY KEY,
|
129
|
-
`developer` INTEGER NOT NULL
|
132
|
+
`developer` INTEGER NOT NULL,
|
133
|
+
`extendedWarranty` INTEGER NOT NULL
|
130
134
|
) TYPE=InnoDB;
|
131
135
|
|
132
136
|
CREATE TABLE `posts` (
|
@@ -154,26 +158,27 @@ CREATE TABLE `tasks` (
|
|
154
158
|
`starting` datetime NOT NULL default '0000-00-00 00:00:00',
|
155
159
|
`ending` datetime NOT NULL default '0000-00-00 00:00:00',
|
156
160
|
PRIMARY KEY (`id`)
|
157
|
-
);
|
161
|
+
) TYPE=InnoDB;
|
158
162
|
|
159
163
|
CREATE TABLE `categories` (
|
160
164
|
`id` int(11) NOT NULL auto_increment,
|
161
165
|
`name` VARCHAR(255) NOT NULL,
|
166
|
+
`type` VARCHAR(255) NOT NULL,
|
162
167
|
PRIMARY KEY (`id`)
|
163
|
-
);
|
168
|
+
) TYPE=InnoDB;
|
164
169
|
|
165
170
|
CREATE TABLE `categories_posts` (
|
166
171
|
`category_id` int(11) NOT NULL,
|
167
172
|
`post_id` int(11) NOT NULL
|
168
|
-
);
|
173
|
+
) TYPE=InnoDB;
|
169
174
|
|
170
175
|
CREATE TABLE `fk_test_has_pk` (
|
171
176
|
`id` INTEGER NOT NULL PRIMARY KEY
|
172
|
-
);
|
177
|
+
) TYPE=InnoDB;
|
173
178
|
|
174
179
|
CREATE TABLE `fk_test_has_fk` (
|
175
180
|
`id` INTEGER NOT NULL PRIMARY KEY,
|
176
181
|
`fk_id` INTEGER NOT NULL,
|
177
182
|
|
178
183
|
FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`)
|
179
|
-
);
|
184
|
+
) TYPE=InnoDB;
|