activerecord 1.13.0 → 1.13.1

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 (68) hide show
  1. data/CHANGELOG +91 -0
  2. data/lib/active_record.rb +2 -2
  3. data/lib/active_record/acts/list.rb +16 -12
  4. data/lib/active_record/acts/tree.rb +2 -2
  5. data/lib/active_record/aggregations.rb +6 -0
  6. data/lib/active_record/associations.rb +38 -16
  7. data/lib/active_record/associations/has_many_association.rb +2 -1
  8. data/lib/active_record/associations/has_one_association.rb +1 -1
  9. data/lib/active_record/base.rb +46 -33
  10. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +33 -9
  11. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +11 -2
  12. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +3 -0
  13. data/lib/active_record/connection_adapters/abstract_adapter.rb +41 -21
  14. data/lib/active_record/connection_adapters/firebird_adapter.rb +414 -0
  15. data/lib/active_record/connection_adapters/mysql_adapter.rb +68 -29
  16. data/lib/active_record/connection_adapters/oci_adapter.rb +141 -21
  17. data/lib/active_record/connection_adapters/postgresql_adapter.rb +82 -21
  18. data/lib/active_record/connection_adapters/sqlite_adapter.rb +3 -3
  19. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +39 -6
  20. data/lib/active_record/fixtures.rb +1 -0
  21. data/lib/active_record/migration.rb +30 -13
  22. data/lib/active_record/validations.rb +18 -7
  23. data/lib/active_record/vendor/mysql.rb +89 -12
  24. data/lib/active_record/version.rb +2 -2
  25. data/rakefile +38 -3
  26. data/test/abstract_unit.rb +5 -0
  27. data/test/aggregations_test.rb +19 -0
  28. data/test/associations_go_eager_test.rb +26 -2
  29. data/test/associations_test.rb +29 -10
  30. data/test/base_test.rb +57 -6
  31. data/test/binary_test.rb +3 -3
  32. data/test/connections/native_db2/connection.rb +1 -1
  33. data/test/connections/native_firebird/connection.rb +24 -0
  34. data/test/connections/native_mysql/connection.rb +1 -1
  35. data/test/connections/native_oci/connection.rb +1 -1
  36. data/test/connections/native_postgresql/connection.rb +6 -6
  37. data/test/connections/native_sqlite/connection.rb +1 -1
  38. data/test/connections/native_sqlite3/connection.rb +1 -1
  39. data/test/connections/native_sqlite3/in_memory_connection.rb +1 -1
  40. data/test/connections/native_sqlserver/connection.rb +1 -1
  41. data/test/connections/native_sqlserver_odbc/connection.rb +1 -1
  42. data/test/default_test_firebird.rb +16 -0
  43. data/test/deprecated_associations_test.rb +1 -1
  44. data/test/finder_test.rb +11 -1
  45. data/test/fixtures/author.rb +30 -30
  46. data/test/fixtures/comment.rb +1 -1
  47. data/test/fixtures/company.rb +3 -1
  48. data/test/fixtures/customer.rb +4 -0
  49. data/test/fixtures/db_definitions/firebird.drop.sql +54 -0
  50. data/test/fixtures/db_definitions/firebird.sql +259 -0
  51. data/test/fixtures/db_definitions/firebird2.drop.sql +2 -0
  52. data/test/fixtures/db_definitions/firebird2.sql +6 -0
  53. data/test/fixtures/db_definitions/oci.sql +8 -0
  54. data/test/fixtures/db_definitions/postgresql.sql +3 -2
  55. data/test/fixtures/developer.rb +10 -0
  56. data/test/fixtures/fixture_database.sqlite +0 -0
  57. data/test/fixtures/fixture_database_2.sqlite +0 -0
  58. data/test/fixtures/mixin.rb +11 -1
  59. data/test/fixtures/mixins.yml +20 -1
  60. data/test/fixtures_test.rb +65 -45
  61. data/test/inheritance_test.rb +1 -1
  62. data/test/migration_test.rb +7 -1
  63. data/test/mixin_test.rb +267 -98
  64. data/test/multiple_db_test.rb +13 -1
  65. data/test/pk_test.rb +1 -0
  66. metadata +11 -5
  67. data/lib/active_record/vendor/mysql411.rb +0 -311
  68. data/test/debug.log +0 -2857
@@ -1,5 +1,5 @@
1
1
  print "Using native SQlite\n"
2
- require 'fixtures/course'
2
+ require_dependency 'fixtures/course'
3
3
  require 'logger'
4
4
  ActiveRecord::Base.logger = Logger.new("debug.log")
5
5
 
@@ -1,5 +1,5 @@
1
1
  print "Using native SQLite3\n"
2
- require 'fixtures/course'
2
+ require_dependency 'fixtures/course'
3
3
  require 'logger'
4
4
  ActiveRecord::Base.logger = Logger.new("debug.log")
5
5
 
@@ -1,5 +1,5 @@
1
1
  print "Using native SQLite3\n"
2
- require 'fixtures/course'
2
+ require_dependency 'fixtures/course'
3
3
  require 'logger'
4
4
  ActiveRecord::Base.logger = Logger.new("debug.log")
5
5
 
@@ -1,5 +1,5 @@
1
1
  print "Using native SQLServer\n"
2
- require 'fixtures/course'
2
+ require_dependency 'fixtures/course'
3
3
  require 'logger'
4
4
 
5
5
  ActiveRecord::Base.logger = Logger.new("debug.log")
@@ -1,5 +1,5 @@
1
1
  print "Using native SQLServer via ODBC\n"
2
- require 'fixtures/course'
2
+ require_dependency 'fixtures/course'
3
3
  require 'logger'
4
4
 
5
5
  ActiveRecord::Base.logger = Logger.new("debug.log")
@@ -0,0 +1,16 @@
1
+ require 'abstract_unit'
2
+ require 'fixtures/default'
3
+
4
+ class DefaultTest < Test::Unit::TestCase
5
+ def test_default_timestamp
6
+ default = Default.new
7
+ assert_instance_of(Time, default.default_timestamp)
8
+ assert_equal(:datetime, default.column_for_attribute(:default_timestamp).type)
9
+
10
+ # Variance should be small; increase if required -- e.g., if test db is on
11
+ # remote host and clocks aren't synchronized.
12
+ t1 = Time.new
13
+ accepted_variance = 1.0
14
+ assert_in_delta(t1.to_f, default.default_timestamp.to_f, accepted_variance)
15
+ end
16
+ end
@@ -312,7 +312,7 @@ class DeprecatedAssociationsTest < Test::Unit::TestCase
312
312
  end
313
313
 
314
314
  def test_has_many_find_all
315
- assert_equal 2, Firm.find_first.find_all_in_clients("type = 'Client'").length
315
+ assert_equal 2, Firm.find_first.find_all_in_clients("#{QUOTED_TYPE} = 'Client'").length
316
316
  assert_equal 1, Firm.find_first.find_all_in_clients("name = 'Summit'").length
317
317
  end
318
318
 
@@ -325,6 +325,16 @@ class FinderTest < Test::Unit::TestCase
325
325
  assert_equal 'fixture_9', last_two_developers.first.name
326
326
  end
327
327
 
328
+ def test_find_all_with_limit_and_offset_and_multiple_order_clauses
329
+ first_three_posts = Post.find :all, :order => 'author_id, id', :limit => 3, :offset => 0
330
+ second_three_posts = Post.find :all, :order => ' author_id,id ', :limit => 3, :offset => 3
331
+ last_posts = Post.find :all, :order => ' author_id, id ', :limit => 3, :offset => 6
332
+
333
+ assert_equal [[0,3],[1,1],[1,2]], first_three_posts.map { |p| [p.author_id, p.id] }
334
+ assert_equal [[1,4],[1,5],[1,6]], second_three_posts.map { |p| [p.author_id, p.id] }
335
+ assert_equal [[2,7]], last_posts.map { |p| [p.author_id, p.id] }
336
+ end
337
+
328
338
  def test_find_all_with_join
329
339
  developers_on_project_one = Developer.find(
330
340
  :all,
@@ -340,7 +350,7 @@ class FinderTest < Test::Unit::TestCase
340
350
  def test_find_by_id_with_conditions_with_or
341
351
  assert_nothing_raised do
342
352
  Post.find([1,2,3],
343
- :conditions => "posts.id <= 3 OR posts.type = 'Post'")
353
+ :conditions => "posts.id <= 3 OR posts.#{QUOTED_TYPE} = 'Post'")
344
354
  end
345
355
  end
346
356
 
@@ -2,45 +2,45 @@ class Author < ActiveRecord::Base
2
2
  has_many :posts
3
3
  has_many :posts_with_comments, :include => :comments, :class_name => "Post"
4
4
  has_many :posts_with_categories, :include => :categories, :class_name => "Post"
5
- has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :class_name => "Post"
5
+ has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :order => "posts.id", :class_name => "Post"
6
6
 
7
7
  has_many :posts_with_callbacks, :class_name => "Post", :before_add => :log_before_adding,
8
- :after_add => :log_after_adding, :before_remove => :log_before_removing,
9
- :after_remove => :log_after_removing
10
- has_many :posts_with_proc_callbacks, :class_name => "Post",
8
+ :after_add => :log_after_adding, :before_remove => :log_before_removing,
9
+ :after_remove => :log_after_removing
10
+ has_many :posts_with_proc_callbacks, :class_name => "Post",
11
11
  :before_add => Proc.new {|o, r| o.post_log << "before_adding#{r.id}"},
12
- :after_add => Proc.new {|o, r| o.post_log << "after_adding#{r.id}"},
13
- :before_remove => Proc.new {|o, r| o.post_log << "before_removing#{r.id}"},
14
- :after_remove => Proc.new {|o, r| o.post_log << "after_removing#{r.id}"}
15
- has_many :posts_with_multiple_callbacks, :class_name => "Post",
12
+ :after_add => Proc.new {|o, r| o.post_log << "after_adding#{r.id}"},
13
+ :before_remove => Proc.new {|o, r| o.post_log << "before_removing#{r.id}"},
14
+ :after_remove => Proc.new {|o, r| o.post_log << "after_removing#{r.id}"}
15
+ has_many :posts_with_multiple_callbacks, :class_name => "Post",
16
16
  :before_add => [:log_before_adding, Proc.new {|o, r| o.post_log << "before_adding_proc#{r.id}"}],
17
- :after_add => [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id}"}]
17
+ :after_add => [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id}"}]
18
18
  has_many :unchangable_posts, :class_name => "Post", :before_add => :raise_exception, :after_add => :log_after_adding
19
19
 
20
20
  attr_accessor :post_log
21
21
 
22
22
  def after_initialize
23
- @post_log = []
23
+ @post_log = []
24
24
  end
25
25
 
26
26
  private
27
- def log_before_adding(object)
28
- @post_log << "before_adding#{object.id}"
29
- end
30
-
31
- def log_after_adding(object)
32
- @post_log << "after_adding#{object.id}"
33
- end
34
-
35
- def log_before_removing(object)
36
- @post_log << "before_removing#{object.id}"
37
- end
38
-
39
- def log_after_removing(object)
40
- @post_log << "after_removing#{object.id}"
41
- end
42
-
43
- def raise_exception(object)
44
- raise Exception.new("You can't add a post")
45
- end
46
- end
27
+ def log_before_adding(object)
28
+ @post_log << "before_adding#{object.id}"
29
+ end
30
+
31
+ def log_after_adding(object)
32
+ @post_log << "after_adding#{object.id}"
33
+ end
34
+
35
+ def log_before_removing(object)
36
+ @post_log << "before_removing#{object.id}"
37
+ end
38
+
39
+ def log_after_removing(object)
40
+ @post_log << "after_removing#{object.id}"
41
+ end
42
+
43
+ def raise_exception(object)
44
+ raise Exception.new("You can't add a post")
45
+ end
46
+ end
@@ -6,7 +6,7 @@ class Comment < ActiveRecord::Base
6
6
  end
7
7
 
8
8
  def self.search_by_type(q)
9
- self.find(:all, :conditions => ['type = ?', q])
9
+ self.find(:all, :conditions => ["#{QUOTED_TYPE} = ?", q])
10
10
  end
11
11
  end
12
12
 
@@ -7,7 +7,9 @@ end
7
7
 
8
8
 
9
9
  class Firm < Company
10
- has_many :clients, :order => "id", :dependent => true, :counter_sql => "SELECT COUNT(*) FROM companies WHERE firm_id = 1 AND (type = 'Client' OR type = 'SpecialClient' OR type = 'VerySpecialClient' )"
10
+ has_many :clients, :order => "id", :dependent => true, :counter_sql =>
11
+ "SELECT COUNT(*) FROM companies WHERE firm_id = 1 " +
12
+ "AND (#{QUOTED_TYPE} = 'Client' OR #{QUOTED_TYPE} = 'SpecialClient' OR #{QUOTED_TYPE} = 'VerySpecialClient' )"
11
13
  has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
12
14
  has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
13
15
  has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => true
@@ -44,4 +44,8 @@ class GpsLocation
44
44
  def longitude
45
45
  gps_location.split("x").last
46
46
  end
47
+
48
+ def ==(other)
49
+ self.latitude == other.latitude && self.longitude == other.longitude
50
+ end
47
51
  end
@@ -0,0 +1,54 @@
1
+ DROP TABLE accounts;
2
+ DROP TABLE companies;
3
+ DROP TABLE topics;
4
+ DROP TABLE developers;
5
+ DROP TABLE projects;
6
+ DROP TABLE developers_projects;
7
+ DROP TABLE orders;
8
+ DROP TABLE customers;
9
+ DROP TABLE movies;
10
+ DROP TABLE subscribers;
11
+ DROP TABLE booleantests;
12
+ DROP TABLE auto_id_tests;
13
+ DROP TABLE entrants;
14
+ DROP TABLE colnametests;
15
+ DROP TABLE mixins;
16
+ DROP TABLE people;
17
+ DROP TABLE binaries;
18
+ DROP TABLE computers;
19
+ DROP TABLE posts;
20
+ DROP TABLE comments;
21
+ DROP TABLE authors;
22
+ DROP TABLE tasks;
23
+ DROP TABLE categories;
24
+ DROP TABLE categories_posts;
25
+ DROP TABLE fk_test_has_fk;
26
+ DROP TABLE fk_test_has_pk;
27
+ DROP TABLE keyboards;
28
+ DROP TABLE defaults;
29
+
30
+ DROP DOMAIN D_BOOLEAN;
31
+
32
+ DROP GENERATOR accounts_seq;
33
+ DROP GENERATOR companies_nonstd_seq;
34
+ DROP GENERATOR topics_seq;
35
+ DROP GENERATOR developers_seq;
36
+ DROP GENERATOR projects_seq;
37
+ DROP GENERATOR orders_seq;
38
+ DROP GENERATOR customers_seq;
39
+ DROP GENERATOR movies_seq;
40
+ DROP GENERATOR booleantests_seq;
41
+ DROP GENERATOR auto_id_tests_seq;
42
+ DROP GENERATOR entrants_seq;
43
+ DROP GENERATOR colnametests_seq;
44
+ DROP GENERATOR mixins_seq;
45
+ DROP GENERATOR people_seq;
46
+ DROP GENERATOR binaries_seq;
47
+ DROP GENERATOR computers_seq;
48
+ DROP GENERATOR posts_seq;
49
+ DROP GENERATOR comments_seq;
50
+ DROP GENERATOR authors_seq;
51
+ DROP GENERATOR tasks_seq;
52
+ DROP GENERATOR categories_seq;
53
+ DROP GENERATOR keyboards_seq;
54
+ DROP GENERATOR defaults_seq;
@@ -0,0 +1,259 @@
1
+ CREATE DOMAIN D_BOOLEAN AS SMALLINT CHECK (VALUE IN (0, 1));
2
+
3
+ CREATE TABLE accounts (
4
+ id BIGINT NOT NULL,
5
+ firm_id BIGINT,
6
+ credit_limit INTEGER,
7
+ PRIMARY KEY (id)
8
+ );
9
+ CREATE GENERATOR accounts_seq;
10
+ SET GENERATOR accounts_seq TO 10000;
11
+
12
+ CREATE TABLE companies (
13
+ id BIGINT NOT NULL,
14
+ "TYPE" VARCHAR(50),
15
+ ruby_type VARCHAR(50),
16
+ firm_id BIGINT,
17
+ name VARCHAR(50),
18
+ client_of INTEGER,
19
+ rating INTEGER DEFAULT 1,
20
+ PRIMARY KEY (id)
21
+ );
22
+ CREATE GENERATOR companies_nonstd_seq;
23
+ SET GENERATOR companies_nonstd_seq TO 10000;
24
+
25
+ CREATE TABLE topics (
26
+ id BIGINT NOT NULL,
27
+ title VARCHAR(255),
28
+ author_name VARCHAR(255),
29
+ author_email_address VARCHAR(255),
30
+ written_on TIMESTAMP,
31
+ bonus_time TIME,
32
+ last_read DATE,
33
+ content VARCHAR(4000),
34
+ approved D_BOOLEAN DEFAULT 1,
35
+ replies_count INTEGER DEFAULT 0,
36
+ parent_id BIGINT,
37
+ "TYPE" VARCHAR(50),
38
+ PRIMARY KEY (id)
39
+ );
40
+ CREATE GENERATOR topics_seq;
41
+ SET GENERATOR topics_seq TO 10000;
42
+
43
+ CREATE TABLE developers (
44
+ id BIGINT NOT NULL,
45
+ name VARCHAR(100),
46
+ salary INTEGER DEFAULT 70000,
47
+ created_at TIMESTAMP,
48
+ updated_at TIMESTAMP,
49
+ PRIMARY KEY (id)
50
+ );
51
+ CREATE GENERATOR developers_seq;
52
+ SET GENERATOR developers_seq TO 10000;
53
+
54
+ CREATE TABLE projects (
55
+ id BIGINT NOT NULL,
56
+ name VARCHAR(100),
57
+ "TYPE" VARCHAR(255),
58
+ PRIMARY KEY (id)
59
+ );
60
+ CREATE GENERATOR projects_seq;
61
+ SET GENERATOR projects_seq TO 10000;
62
+
63
+ CREATE TABLE developers_projects (
64
+ developer_id BIGINT NOT NULL,
65
+ project_id BIGINT NOT NULL,
66
+ joined_on DATE,
67
+ access_level SMALLINT DEFAULT 1
68
+ );
69
+
70
+ CREATE TABLE orders (
71
+ id BIGINT NOT NULL,
72
+ name VARCHAR(100),
73
+ billing_customer_id BIGINT,
74
+ shipping_customer_id BIGINT,
75
+ PRIMARY KEY (id)
76
+ );
77
+ CREATE GENERATOR orders_seq;
78
+ SET GENERATOR orders_seq TO 10000;
79
+
80
+ CREATE TABLE customers (
81
+ id BIGINT NOT NULL,
82
+ name VARCHAR(100),
83
+ balance INTEGER DEFAULT 0,
84
+ address_street VARCHAR(100),
85
+ address_city VARCHAR(100),
86
+ address_country VARCHAR(100),
87
+ gps_location VARCHAR(100),
88
+ PRIMARY KEY (id)
89
+ );
90
+ CREATE GENERATOR customers_seq;
91
+ SET GENERATOR customers_seq TO 10000;
92
+
93
+ CREATE TABLE movies (
94
+ movieid BIGINT NOT NULL,
95
+ name varchar(100),
96
+ PRIMARY KEY (movieid)
97
+ );
98
+ CREATE GENERATOR movies_seq;
99
+ SET GENERATOR movies_seq TO 10000;
100
+
101
+ CREATE TABLE subscribers (
102
+ nick VARCHAR(100) NOT NULL,
103
+ name VARCHAR(100),
104
+ PRIMARY KEY (nick)
105
+ );
106
+
107
+ CREATE TABLE booleantests (
108
+ id BIGINT NOT NULL,
109
+ "VALUE" D_BOOLEAN,
110
+ PRIMARY KEY (id)
111
+ );
112
+ CREATE GENERATOR booleantests_seq;
113
+ SET GENERATOR booleantests_seq TO 10000;
114
+
115
+ CREATE TABLE auto_id_tests (
116
+ auto_id BIGINT NOT NULL,
117
+ "VALUE" INTEGER,
118
+ PRIMARY KEY (auto_id)
119
+ );
120
+ CREATE GENERATOR auto_id_tests_seq;
121
+ SET GENERATOR auto_id_tests_seq TO 10000;
122
+
123
+ CREATE TABLE entrants (
124
+ id BIGINT NOT NULL,
125
+ name VARCHAR(255) NOT NULL,
126
+ course_id INTEGER NOT NULL,
127
+ PRIMARY KEY (id)
128
+ );
129
+ CREATE GENERATOR entrants_seq;
130
+ SET GENERATOR entrants_seq TO 10000;
131
+
132
+ CREATE TABLE colnametests (
133
+ id BIGINT NOT NULL,
134
+ "REFERENCES" INTEGER NOT NULL,
135
+ PRIMARY KEY (id)
136
+ );
137
+ CREATE GENERATOR colnametests_seq;
138
+ SET GENERATOR colnametests_seq TO 10000;
139
+
140
+ CREATE TABLE mixins (
141
+ id BIGINT NOT NULL,
142
+ parent_id BIGINT,
143
+ pos INTEGER,
144
+ created_at TIMESTAMP,
145
+ updated_at TIMESTAMP,
146
+ lft INTEGER,
147
+ rgt INTEGER,
148
+ root_id BIGINT,
149
+ "TYPE" VARCHAR(40),
150
+ PRIMARY KEY (id)
151
+ );
152
+ CREATE GENERATOR mixins_seq;
153
+ SET GENERATOR mixins_seq TO 10000;
154
+
155
+ CREATE TABLE people (
156
+ id BIGINT NOT NULL,
157
+ first_name VARCHAR(40),
158
+ lock_version INTEGER DEFAULT 0 NOT NULL,
159
+ PRIMARY KEY (id)
160
+ );
161
+ CREATE GENERATOR people_seq;
162
+ SET GENERATOR people_seq TO 10000;
163
+
164
+ CREATE TABLE binaries (
165
+ id BIGINT NOT NULL,
166
+ data BLOB,
167
+ PRIMARY KEY (id)
168
+ );
169
+ CREATE GENERATOR binaries_seq;
170
+ SET GENERATOR binaries_seq TO 10000;
171
+
172
+ CREATE TABLE computers (
173
+ id BIGINT NOT NULL,
174
+ developer INTEGER NOT NULL,
175
+ "extendedWarranty" INTEGER NOT NULL,
176
+ PRIMARY KEY (id)
177
+ );
178
+ CREATE GENERATOR computers_seq;
179
+ SET GENERATOR computers_seq TO 10000;
180
+
181
+ CREATE TABLE posts (
182
+ id BIGINT NOT NULL,
183
+ author_id BIGINT,
184
+ title VARCHAR(255) NOT NULL,
185
+ "TYPE" VARCHAR(255) NOT NULL,
186
+ body VARCHAR(3000) NOT NULL,
187
+ PRIMARY KEY (id)
188
+ );
189
+ CREATE GENERATOR posts_seq;
190
+ SET GENERATOR posts_seq TO 10000;
191
+
192
+ CREATE TABLE comments (
193
+ id BIGINT NOT NULL,
194
+ post_id BIGINT NOT NULL,
195
+ "TYPE" VARCHAR(255) NOT NULL,
196
+ body VARCHAR(3000) NOT NULL,
197
+ PRIMARY KEY (id)
198
+ );
199
+ CREATE GENERATOR comments_seq;
200
+ SET GENERATOR comments_seq TO 10000;
201
+
202
+ CREATE TABLE authors (
203
+ id BIGINT NOT NULL,
204
+ name VARCHAR(255) NOT NULL,
205
+ PRIMARY KEY (id)
206
+ );
207
+ CREATE GENERATOR authors_seq;
208
+ SET GENERATOR authors_seq TO 10000;
209
+
210
+ CREATE TABLE tasks (
211
+ id BIGINT NOT NULL,
212
+ "STARTING" TIMESTAMP,
213
+ ending TIMESTAMP,
214
+ PRIMARY KEY (id)
215
+ );
216
+ CREATE GENERATOR tasks_seq;
217
+ SET GENERATOR tasks_seq TO 10000;
218
+
219
+ CREATE TABLE categories (
220
+ id BIGINT NOT NULL,
221
+ name VARCHAR(255) NOT NULL,
222
+ "TYPE" VARCHAR(255) NOT NULL,
223
+ PRIMARY KEY (id)
224
+ );
225
+ CREATE GENERATOR categories_seq;
226
+ SET GENERATOR categories_seq TO 10000;
227
+
228
+ CREATE TABLE categories_posts (
229
+ category_id BIGINT NOT NULL,
230
+ post_id BIGINT NOT NULL,
231
+ PRIMARY KEY (category_id, post_id)
232
+ );
233
+
234
+ CREATE TABLE fk_test_has_pk (
235
+ id BIGINT NOT NULL,
236
+ PRIMARY KEY (id)
237
+ );
238
+
239
+ CREATE TABLE fk_test_has_fk (
240
+ id BIGINT NOT NULL,
241
+ fk_id BIGINT NOT NULL,
242
+ PRIMARY KEY (id),
243
+ FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
244
+ );
245
+
246
+ CREATE TABLE keyboards (
247
+ key_number BIGINT NOT NULL,
248
+ name VARCHAR(50),
249
+ PRIMARY KEY (key_number)
250
+ );
251
+ CREATE GENERATOR keyboards_seq;
252
+ SET GENERATOR keyboards_seq TO 10000;
253
+
254
+ CREATE TABLE defaults (
255
+ id BIGINT NOT NULL,
256
+ default_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
257
+ );
258
+ CREATE GENERATOR defaults_seq;
259
+ SET GENERATOR defaults_seq TO 10000;