activerecord 1.11.1 → 1.12.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 (102) hide show
  1. data/CHANGELOG +198 -0
  2. data/lib/active_record.rb +19 -14
  3. data/lib/active_record/acts/list.rb +8 -6
  4. data/lib/active_record/acts/tree.rb +33 -10
  5. data/lib/active_record/aggregations.rb +1 -7
  6. data/lib/active_record/associations.rb +151 -82
  7. data/lib/active_record/associations/association_collection.rb +25 -0
  8. data/lib/active_record/associations/association_proxy.rb +9 -8
  9. data/lib/active_record/associations/belongs_to_association.rb +19 -5
  10. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +44 -69
  11. data/lib/active_record/associations/has_many_association.rb +6 -14
  12. data/lib/active_record/associations/has_one_association.rb +5 -3
  13. data/lib/active_record/base.rb +344 -130
  14. data/lib/active_record/callbacks.rb +2 -2
  15. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +128 -0
  16. data/lib/active_record/connection_adapters/abstract/database_statements.rb +104 -0
  17. data/lib/active_record/connection_adapters/abstract/quoting.rb +51 -0
  18. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +249 -0
  19. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +245 -0
  20. data/lib/active_record/connection_adapters/abstract_adapter.rb +29 -464
  21. data/lib/active_record/connection_adapters/db2_adapter.rb +40 -10
  22. data/lib/active_record/connection_adapters/mysql_adapter.rb +131 -60
  23. data/lib/active_record/connection_adapters/oci_adapter.rb +106 -26
  24. data/lib/active_record/connection_adapters/postgresql_adapter.rb +211 -62
  25. data/lib/active_record/connection_adapters/sqlite_adapter.rb +193 -44
  26. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +24 -15
  27. data/lib/active_record/fixtures.rb +47 -24
  28. data/lib/active_record/migration.rb +34 -5
  29. data/lib/active_record/observer.rb +32 -2
  30. data/lib/active_record/query_cache.rb +12 -11
  31. data/lib/active_record/schema.rb +58 -0
  32. data/lib/active_record/schema_dumper.rb +84 -0
  33. data/lib/active_record/transactions.rb +1 -3
  34. data/lib/active_record/validations.rb +40 -26
  35. data/lib/active_record/vendor/mysql.rb +6 -0
  36. data/lib/active_record/version.rb +9 -0
  37. data/rakefile +5 -16
  38. data/test/abstract_unit.rb +6 -11
  39. data/test/adapter_test.rb +58 -0
  40. data/test/ar_schema_test.rb +33 -0
  41. data/test/association_callbacks_test.rb +14 -0
  42. data/test/associations_go_eager_test.rb +56 -14
  43. data/test/associations_test.rb +245 -25
  44. data/test/base_test.rb +205 -34
  45. data/test/binary_test.rb +25 -42
  46. data/test/callbacks_test.rb +75 -0
  47. data/test/conditions_scoping_test.rb +136 -0
  48. data/test/connections/native_mysql/connection.rb +0 -4
  49. data/test/connections/native_sqlite3/in_memory_connection.rb +17 -0
  50. data/test/copy_table_sqlite.rb +64 -0
  51. data/test/deprecated_associations_test.rb +7 -6
  52. data/test/deprecated_finder_test.rb +3 -3
  53. data/test/finder_test.rb +33 -3
  54. data/test/fixtures/accounts.yml +5 -0
  55. data/test/fixtures/categories_ordered.yml +7 -0
  56. data/test/fixtures/category.rb +11 -1
  57. data/test/fixtures/comment.rb +22 -2
  58. data/test/fixtures/comments.yml +6 -0
  59. data/test/fixtures/companies.yml +15 -0
  60. data/test/fixtures/company.rb +24 -1
  61. data/test/fixtures/db_definitions/db2.drop.sql +5 -1
  62. data/test/fixtures/db_definitions/db2.sql +15 -1
  63. data/test/fixtures/db_definitions/mysql.drop.sql +2 -0
  64. data/test/fixtures/db_definitions/mysql.sql +17 -2
  65. data/test/fixtures/db_definitions/oci.drop.sql +37 -5
  66. data/test/fixtures/db_definitions/oci.sql +47 -4
  67. data/test/fixtures/db_definitions/oci2.drop.sql +1 -1
  68. data/test/fixtures/db_definitions/oci2.sql +2 -2
  69. data/test/fixtures/db_definitions/postgresql.drop.sql +4 -0
  70. data/test/fixtures/db_definitions/postgresql.sql +33 -4
  71. data/test/fixtures/db_definitions/sqlite.drop.sql +2 -0
  72. data/test/fixtures/db_definitions/sqlite.sql +16 -2
  73. data/test/fixtures/db_definitions/sqlserver.drop.sql +2 -0
  74. data/test/fixtures/db_definitions/sqlserver.sql +16 -2
  75. data/test/fixtures/developer.rb +1 -1
  76. data/test/fixtures/flowers.jpg +0 -0
  77. data/test/fixtures/keyboard.rb +3 -0
  78. data/test/fixtures/mixins.yml +11 -1
  79. data/test/fixtures/order.rb +4 -0
  80. data/test/fixtures/post.rb +4 -0
  81. data/test/fixtures/posts.yml +7 -0
  82. data/test/fixtures/project.rb +1 -0
  83. data/test/fixtures/subject.rb +4 -0
  84. data/test/fixtures/subscriber.rb +2 -4
  85. data/test/fixtures/topics.yml +2 -2
  86. data/test/fixtures_test.rb +79 -7
  87. data/test/inheritance_test.rb +2 -2
  88. data/test/lifecycle_test.rb +14 -6
  89. data/test/migration_test.rb +164 -6
  90. data/test/mixin_test.rb +78 -2
  91. data/test/pk_test.rb +25 -1
  92. data/test/readonly_test.rb +31 -0
  93. data/test/reflection_test.rb +4 -1
  94. data/test/schema_dumper_test.rb +19 -0
  95. data/test/schema_test_postgresql.rb +3 -2
  96. data/test/synonym_test_oci.rb +17 -0
  97. data/test/threaded_connections_test.rb +2 -1
  98. data/test/transactions_test.rb +109 -10
  99. data/test/validations_test.rb +70 -42
  100. metadata +25 -5
  101. data/test/fixtures/associations.png +0 -0
  102. data/test/thread_safety_test.rb +0 -36
@@ -3,9 +3,10 @@ require 'fixtures/company'
3
3
  require 'fixtures/topic'
4
4
  require 'fixtures/entrant'
5
5
  require 'fixtures/developer'
6
+ require 'fixtures/post'
6
7
 
7
8
  class FinderTest < Test::Unit::TestCase
8
- fixtures :companies, :topics, :entrants, :developers
9
+ fixtures :companies, :topics, :entrants, :developers, :posts
9
10
 
10
11
  def test_find
11
12
  assert_equal(topics(:first).title, Topic.find(1).title)
@@ -93,10 +94,14 @@ class FinderTest < Test::Unit::TestCase
93
94
 
94
95
  Topic.find(2).parent
95
96
  end
97
+
98
+ def test_find_only_some_columns
99
+ assert_raises(NoMethodError) { Topic.find(1, :select => "author_name").title }
100
+ end
96
101
 
97
102
  def test_find_on_conditions
98
- assert Topic.find(1, :conditions => "approved = 0")
99
- assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => "approved = 1") }
103
+ assert Topic.find(1, :conditions => ["approved = ?", false])
104
+ assert_raises(ActiveRecord::RecordNotFound) { Topic.find(1, :conditions => ["approved = ?", true]) }
100
105
  end
101
106
 
102
107
  def test_condition_interpolation
@@ -271,6 +276,11 @@ class FinderTest < Test::Unit::TestCase
271
276
  assert_raises(ActiveRecord::StatementInvalid) { Topic.find_by_sql "select 1 from badtable" }
272
277
  end
273
278
 
279
+ def test_find_with_invalid_params
280
+ assert_raises(ArgumentError) { Topic.find :first, :join => "It should be `joins'" }
281
+ assert_raises(ArgumentError) { Topic.find :first, :conditions => '1 = 1', :join => "It should be `joins'" }
282
+ end
283
+
274
284
  def test_find_all_with_limit
275
285
  first_five_developers = Developer.find :all, :order => 'id ASC', :limit => 5
276
286
  assert_equal 5, first_five_developers.length
@@ -307,6 +317,26 @@ class FinderTest < Test::Unit::TestCase
307
317
  assert developer_names.include?('Jamis')
308
318
  end
309
319
 
320
+ def test_find_by_id_with_conditions_with_or
321
+ assert_nothing_raised do
322
+ Post.find([1,2,3],
323
+ :conditions => "posts.id <= 3 OR posts.type = 'Post'")
324
+ end
325
+ end
326
+
327
+ def test_select_value
328
+ assert_equal "37signals", Company.connection.select_value("SELECT name FROM companies WHERE id = 1")
329
+ assert_nil Company.connection.select_value("SELECT name FROM companies WHERE id = -1")
330
+ # make sure we didn't break count...
331
+ assert_equal 0, Company.count_by_sql("SELECT COUNT(*) FROM companies WHERE name = 'Halliburton'")
332
+ assert_equal 1, Company.count_by_sql("SELECT COUNT(*) FROM companies WHERE name = '37signals'")
333
+ end
334
+
335
+ def test_select_values
336
+ assert_equal ["1","2","3","4","5","6","7","8"], Company.connection.select_values("SELECT id FROM companies ORDER BY id")
337
+ assert_equal ["37signals","Summit","Microsoft", "Flamboyant Software", "Ex Nihilo", "RailsCore", "Leetsoft", "Jadedpixel"], Company.connection.select_values("SELECT name FROM companies ORDER BY id")
338
+ end
339
+
310
340
  protected
311
341
  def bind(statement, *vars)
312
342
  if vars.first.is_a?(Hash)
@@ -6,3 +6,8 @@ signals37:
6
6
  unknown:
7
7
  id: 2
8
8
  credit_limit: 50
9
+
10
+ rails_core_account:
11
+ id: 3
12
+ firm_id: 6
13
+ credit_limit: 50
@@ -0,0 +1,7 @@
1
+ --- !omap
2
+ <% 100.times do |i| %>
3
+ - fixture_no_<%= i %>:
4
+ id: <%= i %>
5
+ name: <%= "Category #{i}" %>
6
+ type: Category
7
+ <% end %>
@@ -1,5 +1,15 @@
1
1
  class Category < ActiveRecord::Base
2
2
  has_and_belongs_to_many :posts
3
+
4
+ def self.what_are_you
5
+ 'a category...'
6
+ end
3
7
  end
4
8
 
5
- class SpecialCategory < Category; end;
9
+ class SpecialCategory < Category
10
+
11
+ def self.what_are_you
12
+ 'a special category...'
13
+ end
14
+
15
+ end
@@ -1,7 +1,27 @@
1
1
  class Comment < ActiveRecord::Base
2
2
  belongs_to :post
3
+
4
+ def self.what_are_you
5
+ 'a comment...'
6
+ end
7
+
8
+ def self.search_by_type(q)
9
+ self.find(:all, :conditions => ['type = ?', q])
10
+ end
3
11
  end
4
12
 
5
- class SpecialComment < Comment; end;
13
+ class SpecialComment < Comment;
6
14
 
7
- class VerySpecialComment < Comment; end;
15
+ def self.what_are_you
16
+ 'a special comment...'
17
+ end
18
+
19
+ end;
20
+
21
+ class VerySpecialComment < Comment;
22
+
23
+ def self.what_are_you
24
+ 'a very special comment...'
25
+ end
26
+
27
+ end;
@@ -57,3 +57,9 @@ check_eager_sti_on_associations2:
57
57
  post_id: 5
58
58
  body: Special Type
59
59
  type: SpecialComment
60
+
61
+ eager_other_comment1:
62
+ id: 11
63
+ post_id: 7
64
+ body: go crazy
65
+ type: SpecialComment
@@ -33,3 +33,18 @@ another_client:
33
33
  client_of: 4
34
34
  name: Ex Nihilo
35
35
  ruby_type: Client
36
+
37
+ rails_core:
38
+ id: 6
39
+ name: RailsCore
40
+ type: DependentFirm
41
+
42
+ leetsoft:
43
+ id: 7
44
+ name: Leetsoft
45
+ client_of: 6
46
+
47
+ jadedpixel:
48
+ id: 8
49
+ name: Jadedpixel
50
+ client_of: 6
@@ -1,5 +1,6 @@
1
1
  class Company < ActiveRecord::Base
2
2
  attr_protected :rating
3
+ set_sequence_name :companies_nonstd_seq
3
4
 
4
5
  validates_presence_of :name
5
6
  end
@@ -9,6 +10,8 @@ class Firm < Company
9
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
11
  has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
11
12
  has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
13
+ has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => true
14
+ has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :exclusively_dependent => true
12
15
  has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
13
16
  has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
14
17
  has_many :clients_using_counter_sql, :class_name => "Client",
@@ -24,11 +27,31 @@ class Firm < Company
24
27
  has_one :account, :foreign_key => "firm_id", :dependent => true
25
28
  end
26
29
 
30
+ class DependentFirm < Company
31
+ has_one :account, :foreign_key => "firm_id", :dependent => :nullify
32
+ has_many :companies, :foreign_key => 'client_of', :order => "id", :dependent => :nullify
33
+ end
34
+
35
+
27
36
  class Client < Company
28
37
  belongs_to :firm, :foreign_key => "client_of"
29
38
  belongs_to :firm_with_basic_id, :class_name => "Firm", :foreign_key => "firm_id"
30
39
  belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of"
31
40
  belongs_to :firm_with_condition, :class_name => "Firm", :foreign_key => "client_of", :conditions => "1 = 1"
41
+
42
+ # Record destruction so we can test whether firm.clients.clear has
43
+ # is calling client.destroy, deleting from the database, or setting
44
+ # foreign keys to NULL.
45
+ def self.destroyed_client_ids
46
+ @destroyed_client_ids ||= Hash.new { |h,k| h[k] = [] }
47
+ end
48
+
49
+ before_destroy do |client|
50
+ if client.firm
51
+ Client.destroyed_client_ids[client.firm.id] << client.id
52
+ end
53
+ true
54
+ end
32
55
  end
33
56
 
34
57
 
@@ -45,4 +68,4 @@ class Account < ActiveRecord::Base
45
68
  def validate
46
69
  errors.add_on_empty "credit_limit"
47
70
  end
48
- end
71
+ end
@@ -4,7 +4,9 @@ DROP TABLE topics;
4
4
  DROP TABLE developers;
5
5
  DROP TABLE projects;
6
6
  DROP TABLE developers_projects;
7
+ DROP TABLE orders;
7
8
  DROP TABLE customers;
9
+ DROP TABLE orders;
8
10
  DROP TABLE movies;
9
11
  DROP TABLE subscribers;
10
12
  DROP TABLE booleantests;
@@ -21,4 +23,6 @@ DROP TABLE authors;
21
23
  DROP TABLE tasks;
22
24
  DROP TABLE categories;
23
25
  DROP TABLE categories_posts;
24
-
26
+ DROP TABLE fk_test_has_pk;
27
+ DROP TABLE fk_test_has_fk;
28
+ DROP TABLE keyboards;
@@ -51,7 +51,16 @@ CREATE TABLE projects (
51
51
  CREATE TABLE developers_projects (
52
52
  developer_id int NOT NULL,
53
53
  project_id int NOT NULL,
54
- joined_on date default NULL
54
+ joined_on date default NULL,
55
+ access_level smallint default 1
56
+ );
57
+
58
+ CREATE TABLE orders (
59
+ id int generated by default as identity (start with +10000),
60
+ name varchar(100) default NULL,
61
+ billing_customer_id int default NULL,
62
+ shipping_customer_id int default NULL,
63
+ PRIMARY KEY (id)
55
64
  );
56
65
 
57
66
  CREATE TABLE customers (
@@ -170,6 +179,11 @@ CREATE TABLE categories_posts (
170
179
  post_id int NOT NULL
171
180
  );
172
181
 
182
+ CREATE TABLE keyboards (
183
+ key_number int generated by default as identity (start with +10000),
184
+ name VARCHAR(255)
185
+ );
186
+
173
187
  CREATE TABLE fk_test_has_pk (
174
188
  id INTEGER NOT NULL PRIMARY KEY
175
189
  );
@@ -5,6 +5,7 @@ DROP TABLE developers;
5
5
  DROP TABLE projects;
6
6
  DROP TABLE developers_projects;
7
7
  DROP TABLE customers;
8
+ DROP TABLE orders;
8
9
  DROP TABLE movies;
9
10
  DROP TABLE subscribers;
10
11
  DROP TABLE booleantests;
@@ -23,3 +24,4 @@ DROP TABLE categories;
23
24
  DROP TABLE categories_posts;
24
25
  DROP TABLE fk_test_has_fk;
25
26
  DROP TABLE fk_test_has_pk;
27
+ DROP TABLE keyboards;
@@ -26,7 +26,7 @@ CREATE TABLE `topics` (
26
26
  `bonus_time` time default NULL,
27
27
  `last_read` date default NULL,
28
28
  `content` text,
29
- `approved` tinyint(1) default 1,
29
+ `approved` tinyint default 1,
30
30
  `replies_count` int(11) default 0,
31
31
  `parent_id` int(11) default NULL,
32
32
  `type` varchar(50) default NULL,
@@ -52,7 +52,16 @@ CREATE TABLE `projects` (
52
52
  CREATE TABLE `developers_projects` (
53
53
  `developer_id` int(11) NOT NULL,
54
54
  `project_id` int(11) NOT NULL,
55
- `joined_on` date default NULL
55
+ `joined_on` date default NULL,
56
+ `access_level` smallint default 1
57
+ ) TYPE=InnoDB;
58
+
59
+ CREATE TABLE `orders` (
60
+ `id` int(11) NOT NULL auto_increment,
61
+ `name` varchar(100) default NULL,
62
+ `billing_customer_id` int(11) default NULL,
63
+ `shipping_customer_id` int(11) default NULL,
64
+ PRIMARY KEY (`id`)
56
65
  ) TYPE=InnoDB;
57
66
 
58
67
  CREATE TABLE `customers` (
@@ -182,3 +191,9 @@ CREATE TABLE `fk_test_has_fk` (
182
191
 
183
192
  FOREIGN KEY (`fk_id`) REFERENCES `fk_test_has_pk`(`id`)
184
193
  ) TYPE=InnoDB;
194
+
195
+
196
+ CREATE TABLE `keyboards` (
197
+ `key_number` int(11) NOT NULL auto_increment primary key,
198
+ `name` varchar(50) default NULL
199
+ );
@@ -1,10 +1,13 @@
1
1
  drop table accounts;
2
2
  drop table companies;
3
3
  drop table topics;
4
+ drop synonym subjects;
5
+ drop table developers_projects;
6
+ drop table computers;
4
7
  drop table developers;
5
8
  drop table projects;
6
- drop table developers_projects;
7
9
  drop table customers;
10
+ drop table orders;
8
11
  drop table movies;
9
12
  drop table subscribers;
10
13
  drop table booleantests;
@@ -14,10 +17,39 @@ drop table colnametests;
14
17
  drop table mixins;
15
18
  drop table people;
16
19
  drop table binaries;
17
- drop table posts;
18
20
  drop table comments;
19
21
  drop table authors;
20
- drop table computers;
21
- drop table categories;
22
+ drop table tasks;
22
23
  drop table categories_posts;
23
- drop sequence rails_sequence;
24
+ drop table categories;
25
+ drop table posts;
26
+ drop table fk_test_has_pk;
27
+ drop table fk_test_has_fk;
28
+ drop table keyboards;
29
+ drop sequence accounts_seq;
30
+ drop sequence companies_nonstd_seq;
31
+ drop sequence topics_seq;
32
+ drop sequence developers_seq;
33
+ drop sequence projects_seq;
34
+ drop sequence developers_projects_seq;
35
+ drop sequence customers_seq;
36
+ drop sequence orders_seq;
37
+ drop sequence movies_seq;
38
+ drop sequence subscribers_seq;
39
+ drop sequence booleantests_seq;
40
+ drop sequence auto_id_tests_seq;
41
+ drop sequence entrants_seq;
42
+ drop sequence colnametests_seq;
43
+ drop sequence mixins_seq;
44
+ drop sequence people_seq;
45
+ drop sequence binaries_seq;
46
+ drop sequence posts_seq;
47
+ drop sequence comments_seq;
48
+ drop sequence authors_seq;
49
+ drop sequence tasks_seq;
50
+ drop sequence computers_seq;
51
+ drop sequence categories_seq;
52
+ drop sequence categories_posts_seq;
53
+ drop sequence fk_test_has_pk_seq;
54
+ drop sequence fk_test_has_fk_seq;
55
+ drop sequence keyboards_seq;
@@ -1,5 +1,3 @@
1
- create sequence rails_sequence minvalue 10000;
2
-
3
1
  create table companies (
4
2
  id integer not null,
5
3
  type varchar(50) default null,
@@ -12,12 +10,17 @@ create table companies (
12
10
  primary key (id)
13
11
  );
14
12
 
13
+ -- non-standard sequence name used to test set_sequence_name
14
+ --
15
+ create sequence companies_nonstd_seq minvalue 10000;
16
+
15
17
  create table accounts (
16
18
  id integer not null,
17
19
  firm_id integer default null references companies initially deferred disable,
18
20
  credit_limit integer default null,
19
21
  primary key (id)
20
22
  );
23
+ create sequence accounts_seq minvalue 10000;
21
24
 
22
25
  create table topics (
23
26
  id integer not null,
@@ -50,6 +53,9 @@ create table topics (
50
53
  type varchar(50) default null,
51
54
  primary key (id)
52
55
  );
56
+ create sequence topics_seq minvalue 10000;
57
+
58
+ create synonym subjects for topics;
53
59
 
54
60
  create table developers (
55
61
  id integer not null,
@@ -59,6 +65,7 @@ create table developers (
59
65
  updated_at timestamp default null,
60
66
  primary key (id)
61
67
  );
68
+ create sequence developers_seq minvalue 10000;
62
69
 
63
70
  create table projects (
64
71
  id integer not null,
@@ -66,11 +73,13 @@ create table projects (
66
73
  type varchar(255) default null,
67
74
  primary key (id)
68
75
  );
76
+ create sequence projects_seq minvalue 10000;
69
77
 
70
78
  create table developers_projects (
71
79
  developer_id integer not null references developers initially deferred disable,
72
80
  project_id integer not null references projects initially deferred disable,
73
- joined_on timestamp default null
81
+ joined_on timestamp default null,
82
+ access_level integer default 1
74
83
  );
75
84
  -- Try again for 8i
76
85
  create table developers_projects (
@@ -78,6 +87,16 @@ create table developers_projects (
78
87
  project_id integer not null references projects initially deferred disable,
79
88
  joined_on date default null
80
89
  );
90
+ create sequence developers_projects_seq minvalue 10000;
91
+
92
+ create table orders (
93
+ id integer not null,
94
+ name varchar(100) default null,
95
+ billing_customer_id integer default null,
96
+ shipping_customer_id integer default null,
97
+ primary key (id)
98
+ );
99
+ create sequence orders_seq minvalue 10000;
81
100
 
82
101
  create table customers (
83
102
  id integer not null,
@@ -89,42 +108,49 @@ create table customers (
89
108
  gps_location varchar(100) default null,
90
109
  primary key (id)
91
110
  );
111
+ create sequence customers_seq minvalue 10000;
92
112
 
93
113
  create table movies (
94
114
  movieid integer not null,
95
115
  name varchar(100) default null,
96
116
  primary key (movieid)
97
117
  );
118
+ create sequence movies_seq minvalue 10000;
98
119
 
99
120
  create table subscribers (
100
121
  nick varchar(100) not null,
101
122
  name varchar(100) default null,
102
123
  primary key (nick)
103
124
  );
125
+ create sequence subscribers_seq minvalue 10000;
104
126
 
105
127
  create table booleantests (
106
128
  id integer not null,
107
129
  value integer default null,
108
130
  primary key (id)
109
131
  );
132
+ create sequence booleantests_seq minvalue 10000;
110
133
 
111
134
  create table auto_id_tests (
112
135
  auto_id integer not null,
113
136
  value integer default null,
114
137
  primary key (auto_id)
115
138
  );
139
+ create sequence auto_id_tests_seq minvalue 10000;
116
140
 
117
141
  create table entrants (
118
142
  id integer not null primary key,
119
143
  name varchar(255) not null,
120
144
  course_id integer not null
121
145
  );
146
+ create sequence entrants_seq minvalue 10000;
122
147
 
123
148
  create table colnametests (
124
149
  id integer not null,
125
150
  references integer not null,
126
151
  primary key (id)
127
152
  );
153
+ create sequence colnametests_seq minvalue 10000;
128
154
 
129
155
  create table mixins (
130
156
  id integer not null,
@@ -151,6 +177,7 @@ create table mixins (
151
177
  updated_at date default null,
152
178
  primary key (id)
153
179
  );
180
+ create sequence mixins_seq minvalue 10000;
154
181
 
155
182
  create table people (
156
183
  id integer not null,
@@ -158,18 +185,21 @@ create table people (
158
185
  lock_version integer default 0,
159
186
  primary key (id)
160
187
  );
188
+ create sequence people_seq minvalue 10000;
161
189
 
162
190
  create table binaries (
163
191
  id integer not null,
164
192
  data blob null,
165
193
  primary key (id)
166
194
  );
195
+ create sequence binaries_seq minvalue 10000;
167
196
 
168
197
  create table computers (
169
198
  id integer not null primary key,
170
199
  developer integer not null references developers initially deferred disable,
171
- extendedWarranty integer not null
200
+ "extendedWarranty" integer not null
172
201
  );
202
+ create sequence computers_seq minvalue 10000;
173
203
 
174
204
  create table posts (
175
205
  id integer not null primary key,
@@ -178,6 +208,7 @@ create table posts (
178
208
  type varchar(255) default null,
179
209
  body varchar(3000) default null
180
210
  );
211
+ create sequence posts_seq minvalue 10000;
181
212
 
182
213
  create table comments (
183
214
  id integer not null primary key,
@@ -185,34 +216,46 @@ create table comments (
185
216
  type varchar(255) default null,
186
217
  body varchar(3000) default null
187
218
  );
219
+ create sequence comments_seq minvalue 10000;
188
220
 
189
221
  create table authors (
190
222
  id integer not null primary key,
191
223
  name varchar(255) default null
192
224
  );
225
+ create sequence authors_seq minvalue 10000;
193
226
 
194
227
  create table tasks (
195
228
  id integer not null primary key,
196
229
  starting date default null,
197
230
  ending date default null
198
231
  );
232
+ create sequence tasks_seq minvalue 10000;
199
233
 
200
234
  create table categories (
201
235
  id integer not null primary key,
202
236
  name varchar(255) default null,
203
237
  type varchar(255) default null
204
238
  );
239
+ create sequence categories_seq minvalue 10000;
205
240
 
206
241
  create table categories_posts (
207
242
  category_id integer not null references categories initially deferred disable,
208
243
  post_id integer not null references posts initially deferred disable
209
244
  );
245
+ create sequence categories_posts_seq minvalue 10000;
210
246
 
211
247
  create table fk_test_has_pk (
212
248
  id integer not null primary key
213
249
  );
250
+ create sequence fk_test_has_pk_seq minvalue 10000;
214
251
 
215
252
  create table fk_test_has_fk (
216
253
  id integer not null primary key,
217
254
  fk_id integer not null references fk_test_has_fk initially deferred disable
218
255
  );
256
+ create sequence fk_test_has_fk_seq minvalue 10000;
257
+
258
+ create table keyboards (
259
+ key_number integer not null,
260
+ name varchar(50) default null
261
+ );