activerecord 1.13.2 → 1.14.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.
- data/CHANGELOG +452 -10
- data/RUNNING_UNIT_TESTS +1 -1
- data/lib/active_record.rb +5 -2
- data/lib/active_record/acts/list.rb +1 -1
- data/lib/active_record/acts/tree.rb +29 -25
- data/lib/active_record/aggregations.rb +3 -2
- data/lib/active_record/associations.rb +783 -337
- data/lib/active_record/associations/association_collection.rb +7 -12
- data/lib/active_record/associations/association_proxy.rb +62 -24
- data/lib/active_record/associations/belongs_to_association.rb +27 -46
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +50 -0
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +38 -38
- data/lib/active_record/associations/has_many_association.rb +61 -56
- data/lib/active_record/associations/has_many_through_association.rb +144 -0
- data/lib/active_record/associations/has_one_association.rb +22 -16
- data/lib/active_record/base.rb +482 -182
- data/lib/active_record/calculations.rb +225 -0
- data/lib/active_record/callbacks.rb +7 -7
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +162 -47
- data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +2 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +21 -1
- data/lib/active_record/connection_adapters/abstract_adapter.rb +34 -2
- data/lib/active_record/connection_adapters/db2_adapter.rb +107 -61
- data/lib/active_record/connection_adapters/mysql_adapter.rb +29 -6
- data/lib/active_record/connection_adapters/openbase_adapter.rb +349 -0
- data/lib/active_record/connection_adapters/{oci_adapter.rb → oracle_adapter.rb} +125 -59
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +24 -21
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +47 -8
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +36 -16
- data/lib/active_record/connection_adapters/sybase_adapter.rb +684 -0
- data/lib/active_record/fixtures.rb +42 -17
- data/lib/active_record/locking.rb +36 -15
- data/lib/active_record/migration.rb +111 -8
- data/lib/active_record/observer.rb +25 -1
- data/lib/active_record/reflection.rb +103 -41
- data/lib/active_record/schema.rb +2 -2
- data/lib/active_record/schema_dumper.rb +55 -18
- data/lib/active_record/timestamp.rb +6 -6
- data/lib/active_record/validations.rb +65 -40
- data/lib/active_record/vendor/db2.rb +10 -5
- data/lib/active_record/vendor/simple.rb +693 -702
- data/lib/active_record/version.rb +2 -2
- data/rakefile +4 -4
- data/test/aaa_create_tables_test.rb +25 -6
- data/test/abstract_unit.rb +39 -1
- data/test/adapter_test.rb +31 -4
- data/test/associations_cascaded_eager_loading_test.rb +106 -0
- data/test/associations_go_eager_test.rb +85 -16
- data/test/associations_join_model_test.rb +338 -0
- data/test/associations_test.rb +129 -50
- data/test/base_test.rb +204 -49
- data/test/binary_test.rb +1 -1
- data/test/calculations_test.rb +169 -0
- data/test/callbacks_test.rb +5 -23
- data/test/class_inheritable_attributes_test.rb +1 -1
- data/test/column_alias_test.rb +1 -1
- data/test/connections/native_mysql/connection.rb +1 -0
- data/test/connections/native_openbase/connection.rb +22 -0
- data/test/connections/{native_oci → native_oracle}/connection.rb +7 -9
- data/test/connections/native_sqlite/connection.rb +1 -1
- data/test/connections/native_sqlite3/connection.rb +1 -0
- data/test/connections/native_sqlite3/in_memory_connection.rb +1 -0
- data/test/connections/native_sybase/connection.rb +24 -0
- data/test/defaults_test.rb +18 -0
- data/test/deprecated_associations_test.rb +2 -2
- data/test/deprecated_finder_test.rb +0 -6
- data/test/finder_test.rb +26 -23
- data/test/fixtures/accounts.yml +10 -0
- data/test/fixtures/author.rb +31 -6
- data/test/fixtures/author_favorites.yml +4 -0
- data/test/fixtures/categories/special_categories.yml +9 -0
- data/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
- data/test/fixtures/categories_posts.yml +4 -0
- data/test/fixtures/categorization.rb +5 -0
- data/test/fixtures/categorizations.yml +11 -0
- data/test/fixtures/category.rb +6 -0
- data/test/fixtures/company.rb +17 -5
- data/test/fixtures/company_in_module.rb +19 -5
- data/test/fixtures/db_definitions/db2.drop.sql +3 -0
- data/test/fixtures/db_definitions/db2.sql +121 -100
- data/test/fixtures/db_definitions/db22.sql +2 -2
- data/test/fixtures/db_definitions/firebird.drop.sql +4 -0
- data/test/fixtures/db_definitions/firebird.sql +26 -0
- data/test/fixtures/db_definitions/mysql.drop.sql +3 -0
- data/test/fixtures/db_definitions/mysql.sql +21 -1
- data/test/fixtures/db_definitions/openbase.drop.sql +2 -0
- data/test/fixtures/db_definitions/openbase.sql +282 -0
- data/test/fixtures/db_definitions/openbase2.drop.sql +2 -0
- data/test/fixtures/db_definitions/openbase2.sql +7 -0
- data/test/fixtures/db_definitions/{oci.drop.sql → oracle.drop.sql} +6 -0
- data/test/fixtures/db_definitions/{oci.sql → oracle.sql} +25 -4
- data/test/fixtures/db_definitions/{oci2.drop.sql → oracle2.drop.sql} +0 -0
- data/test/fixtures/db_definitions/{oci2.sql → oracle2.sql} +0 -0
- data/test/fixtures/db_definitions/postgresql.drop.sql +4 -0
- data/test/fixtures/db_definitions/postgresql.sql +22 -1
- data/test/fixtures/db_definitions/schema.rb +32 -0
- data/test/fixtures/db_definitions/sqlite.drop.sql +3 -0
- data/test/fixtures/db_definitions/sqlite.sql +18 -0
- data/test/fixtures/db_definitions/sqlserver.drop.sql +3 -0
- data/test/fixtures/db_definitions/sqlserver.sql +23 -3
- data/test/fixtures/db_definitions/sybase.drop.sql +31 -0
- data/test/fixtures/db_definitions/sybase.sql +204 -0
- data/test/fixtures/db_definitions/sybase2.drop.sql +4 -0
- data/test/fixtures/db_definitions/sybase2.sql +5 -0
- data/test/fixtures/developers.yml +6 -1
- data/test/fixtures/developers_projects.yml +4 -0
- data/test/fixtures/funny_jokes.yml +14 -0
- data/test/fixtures/joke.rb +6 -0
- data/test/fixtures/legacy_thing.rb +3 -0
- data/test/fixtures/legacy_things.yml +3 -0
- data/test/fixtures/mixin.rb +1 -1
- data/test/fixtures/person.rb +4 -1
- data/test/fixtures/post.rb +26 -1
- data/test/fixtures/project.rb +1 -0
- data/test/fixtures/reader.rb +4 -0
- data/test/fixtures/readers.yml +4 -0
- data/test/fixtures/reply.rb +2 -1
- data/test/fixtures/tag.rb +5 -0
- data/test/fixtures/tagging.rb +6 -0
- data/test/fixtures/taggings.yml +18 -0
- data/test/fixtures/tags.yml +7 -0
- data/test/fixtures/tasks.yml +2 -2
- data/test/fixtures/topic.rb +2 -2
- data/test/fixtures/topics.yml +1 -0
- data/test/fixtures_test.rb +47 -13
- data/test/inheritance_test.rb +2 -2
- data/test/locking_test.rb +15 -1
- data/test/method_scoping_test.rb +248 -13
- data/test/migration_test.rb +68 -11
- data/test/mixin_nested_set_test.rb +1 -1
- data/test/modules_test.rb +6 -1
- data/test/readonly_test.rb +1 -1
- data/test/reflection_test.rb +63 -9
- data/test/schema_dumper_test.rb +41 -0
- data/test/{synonym_test_oci.rb → synonym_test_oracle.rb} +1 -1
- data/test/threaded_connections_test.rb +10 -0
- data/test/unconnected_test.rb +12 -5
- data/test/validations_test.rb +197 -10
- metadata +295 -260
- data/test/fixtures/db_definitions/create_oracle_db.bat +0 -0
- data/test/fixtures/db_definitions/create_oracle_db.sh +0 -0
- data/test/fixtures/fixture_database.sqlite +0 -0
- data/test/fixtures/fixture_database_2.sqlite +0 -0
data/test/fixtures/category.rb
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
class Category < ActiveRecord::Base
|
|
2
2
|
has_and_belongs_to_many :posts
|
|
3
|
+
has_and_belongs_to_many :special_posts, :class_name => "Post"
|
|
4
|
+
has_and_belongs_to_many :hello_posts, :class_name => "Post", :conditions => "\#{aliased_table_name}.body = 'hello'"
|
|
5
|
+
has_and_belongs_to_many :nonexistent_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'nonexistent'"
|
|
3
6
|
|
|
4
7
|
def self.what_are_you
|
|
5
8
|
'a category...'
|
|
6
9
|
end
|
|
10
|
+
|
|
11
|
+
has_many :categorizations
|
|
12
|
+
has_many :authors, :through => :categorizations, :select => 'authors.*, categorizations.post_id'
|
|
7
13
|
end
|
|
8
14
|
|
|
9
15
|
class SpecialCategory < Category
|
data/test/fixtures/company.rb
CHANGED
|
@@ -3,17 +3,20 @@ class Company < ActiveRecord::Base
|
|
|
3
3
|
set_sequence_name :companies_nonstd_seq
|
|
4
4
|
|
|
5
5
|
validates_presence_of :name
|
|
6
|
+
|
|
7
|
+
has_one :dummy_account, :foreign_key => "firm_id", :class_name => "Account"
|
|
6
8
|
end
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
class Firm < Company
|
|
10
|
-
has_many :clients, :order => "id", :dependent =>
|
|
12
|
+
has_many :clients, :order => "id", :dependent => :destroy, :counter_sql =>
|
|
11
13
|
"SELECT COUNT(*) FROM companies WHERE firm_id = 1 " +
|
|
12
14
|
"AND (#{QUOTED_TYPE} = 'Client' OR #{QUOTED_TYPE} = 'SpecialClient' OR #{QUOTED_TYPE} = 'VerySpecialClient' )"
|
|
13
15
|
has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
|
|
14
16
|
has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
|
|
15
|
-
has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent =>
|
|
16
|
-
has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :
|
|
17
|
+
has_many :dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :destroy
|
|
18
|
+
has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all
|
|
19
|
+
has_many :limited_clients, :class_name => "Client", :order => "id", :limit => 1
|
|
17
20
|
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
|
|
18
21
|
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
|
|
19
22
|
has_many :clients_using_counter_sql, :class_name => "Client",
|
|
@@ -26,7 +29,7 @@ class Firm < Company
|
|
|
26
29
|
:finder_sql => 'SELECT * FROM companies WHERE client_of = 1000',
|
|
27
30
|
:counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = 1000'
|
|
28
31
|
|
|
29
|
-
has_one :account, :foreign_key => "firm_id", :dependent =>
|
|
32
|
+
has_one :account, :foreign_key => "firm_id", :dependent => :destroy
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
class DependentFirm < Company
|
|
@@ -39,7 +42,7 @@ class Client < Company
|
|
|
39
42
|
belongs_to :firm, :foreign_key => "client_of"
|
|
40
43
|
belongs_to :firm_with_basic_id, :class_name => "Firm", :foreign_key => "firm_id"
|
|
41
44
|
belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of"
|
|
42
|
-
belongs_to :firm_with_condition, :class_name => "Firm", :foreign_key => "client_of", :conditions => "1 = 1
|
|
45
|
+
belongs_to :firm_with_condition, :class_name => "Firm", :foreign_key => "client_of", :conditions => ["1 = ?", 1]
|
|
43
46
|
|
|
44
47
|
# Record destruction so we can test whether firm.clients.clear has
|
|
45
48
|
# is calling client.destroy, deleting from the database, or setting
|
|
@@ -54,6 +57,15 @@ class Client < Company
|
|
|
54
57
|
end
|
|
55
58
|
true
|
|
56
59
|
end
|
|
60
|
+
|
|
61
|
+
# Used to test that read and question methods are not generated for these attributes
|
|
62
|
+
def ruby_type
|
|
63
|
+
read_attribute :ruby_type
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def rating?
|
|
67
|
+
query_attribute :rating
|
|
68
|
+
end
|
|
57
69
|
end
|
|
58
70
|
|
|
59
71
|
|
|
@@ -5,13 +5,13 @@ module MyApplication
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
class Firm < Company
|
|
8
|
-
has_many :clients, :order => "id", :dependent =>
|
|
8
|
+
has_many :clients, :order => "id", :dependent => :destroy
|
|
9
9
|
has_many :clients_sorted_desc, :class_name => "Client", :order => "id DESC"
|
|
10
10
|
has_many :clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id"
|
|
11
11
|
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
|
|
12
12
|
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
|
|
13
13
|
|
|
14
|
-
has_one :account, :dependent =>
|
|
14
|
+
has_one :account, :dependent => :destroy
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
class Client < Company
|
|
@@ -33,11 +33,25 @@ module MyApplication
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
module Billing
|
|
38
|
+
class Firm < ActiveRecord::Base
|
|
39
|
+
self.table_name = 'companies'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
module Nested
|
|
43
|
+
class Firm < ActiveRecord::Base
|
|
44
|
+
self.table_name = 'companies'
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
38
48
|
class Account < ActiveRecord::Base
|
|
39
|
-
belongs_to :firm, :class_name =>
|
|
40
|
-
|
|
49
|
+
belongs_to :firm, :class_name => 'MyApplication::Business::Firm'
|
|
50
|
+
belongs_to :qualified_billing_firm, :class_name => 'MyApplication::Billing::Firm'
|
|
51
|
+
belongs_to :unqualified_billing_firm, :class_name => 'Firm'
|
|
52
|
+
belongs_to :nested_qualified_billing_firm, :class_name => 'MyApplication::Billing::Nested::Firm'
|
|
53
|
+
belongs_to :nested_unqualified_billing_firm, :class_name => 'Nested::Firm'
|
|
54
|
+
|
|
41
55
|
protected
|
|
42
56
|
def validate
|
|
43
57
|
errors.add_on_empty "credit_limit"
|
|
@@ -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_pk;
|
|
26
28
|
DROP TABLE fk_test_has_fk;
|
|
27
29
|
DROP TABLE keyboards;
|
|
30
|
+
DROP TABLE legacy_things;
|
|
@@ -1,196 +1,217 @@
|
|
|
1
1
|
CREATE TABLE accounts (
|
|
2
|
-
id
|
|
3
|
-
firm_id
|
|
4
|
-
credit_limit
|
|
2
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
3
|
+
firm_id INT DEFAULT NULL,
|
|
4
|
+
credit_limit INT DEFAULT NULL,
|
|
5
|
+
PRIMARY KEY (id)
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
CREATE TABLE funny_jokes (
|
|
9
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
10
|
+
name VARCHAR(50) DEFAULT NULL,
|
|
5
11
|
PRIMARY KEY (id)
|
|
6
12
|
);
|
|
7
13
|
|
|
8
14
|
CREATE TABLE companies (
|
|
9
|
-
id
|
|
10
|
-
type
|
|
11
|
-
ruby_type
|
|
12
|
-
firm_id
|
|
13
|
-
name
|
|
14
|
-
client_of
|
|
15
|
-
rating
|
|
15
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
16
|
+
type VARCHAR(50) DEFAULT NULL,
|
|
17
|
+
ruby_type VARCHAR(50) DEFAULT NULL,
|
|
18
|
+
firm_id INT DEFAULT NULL,
|
|
19
|
+
name VARCHAR(50) DEFAULT NULL,
|
|
20
|
+
client_of INT DEFAULT NULL,
|
|
21
|
+
rating INT DEFAULT 1,
|
|
16
22
|
PRIMARY KEY (id)
|
|
17
23
|
);
|
|
18
24
|
|
|
19
25
|
CREATE TABLE topics (
|
|
20
|
-
id
|
|
21
|
-
title
|
|
22
|
-
author_name
|
|
23
|
-
author_email_address
|
|
24
|
-
written_on
|
|
25
|
-
bonus_time
|
|
26
|
-
last_read
|
|
27
|
-
content
|
|
28
|
-
approved
|
|
29
|
-
replies_count
|
|
30
|
-
parent_id
|
|
31
|
-
type
|
|
26
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
27
|
+
title VARCHAR(255) DEFAULT NULL,
|
|
28
|
+
author_name VARCHAR(255) DEFAULT NULL,
|
|
29
|
+
author_email_address VARCHAR(255) DEFAULT NULL,
|
|
30
|
+
written_on TIMESTAMP DEFAULT NULL,
|
|
31
|
+
bonus_time TIME DEFAULT NULL,
|
|
32
|
+
last_read DATE DEFAULT NULL,
|
|
33
|
+
content VARCHAR(3000),
|
|
34
|
+
approved SMALLINT DEFAULT 1,
|
|
35
|
+
replies_count INT DEFAULT 0,
|
|
36
|
+
parent_id INT DEFAULT NULL,
|
|
37
|
+
type VARCHAR(50) DEFAULT NULL,
|
|
32
38
|
PRIMARY KEY (id)
|
|
33
39
|
);
|
|
34
40
|
|
|
35
41
|
CREATE TABLE developers (
|
|
36
|
-
id
|
|
37
|
-
name
|
|
38
|
-
salary
|
|
39
|
-
created_at
|
|
40
|
-
updated_at
|
|
42
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
43
|
+
name VARCHAR(100) DEFAULT NULL,
|
|
44
|
+
salary INT DEFAULT 70000,
|
|
45
|
+
created_at TIMESTAMP DEFAULT NULL,
|
|
46
|
+
updated_at TIMESTAMP DEFAULT NULL,
|
|
41
47
|
PRIMARY KEY (id)
|
|
42
48
|
);
|
|
43
49
|
|
|
44
50
|
CREATE TABLE projects (
|
|
45
|
-
id
|
|
46
|
-
name
|
|
47
|
-
type
|
|
51
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
52
|
+
name VARCHAR(100) DEFAULT NULL,
|
|
53
|
+
type VARCHAR(255) DEFAULT NULL,
|
|
48
54
|
PRIMARY KEY (id)
|
|
49
55
|
);
|
|
50
56
|
|
|
51
57
|
CREATE TABLE developers_projects (
|
|
52
|
-
developer_id
|
|
53
|
-
project_id
|
|
54
|
-
joined_on
|
|
55
|
-
access_level
|
|
58
|
+
developer_id INT NOT NULL,
|
|
59
|
+
project_id INT NOT NULL,
|
|
60
|
+
joined_on DATE DEFAULT NULL,
|
|
61
|
+
access_level SMALLINT DEFAULT 1
|
|
56
62
|
);
|
|
57
63
|
|
|
58
64
|
CREATE TABLE orders (
|
|
59
|
-
id
|
|
60
|
-
name
|
|
61
|
-
billing_customer_id
|
|
62
|
-
shipping_customer_id
|
|
65
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
66
|
+
name VARCHAR(100) DEFAULT NULL,
|
|
67
|
+
billing_customer_id INT DEFAULT NULL,
|
|
68
|
+
shipping_customer_id INT DEFAULT NULL,
|
|
63
69
|
PRIMARY KEY (id)
|
|
64
70
|
);
|
|
65
71
|
|
|
66
72
|
CREATE TABLE customers (
|
|
67
|
-
id
|
|
68
|
-
name
|
|
69
|
-
balance
|
|
70
|
-
address_street
|
|
71
|
-
address_city
|
|
72
|
-
address_country
|
|
73
|
-
gps_location
|
|
73
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
74
|
+
name VARCHAR(100) DEFAULT NULL,
|
|
75
|
+
balance INT DEFAULT 0,
|
|
76
|
+
address_street VARCHAR(100) DEFAULT NULL,
|
|
77
|
+
address_city VARCHAR(100) DEFAULT NULL,
|
|
78
|
+
address_country VARCHAR(100) DEFAULT NULL,
|
|
79
|
+
gps_location VARCHAR(100) DEFAULT NULL,
|
|
74
80
|
PRIMARY KEY (id)
|
|
75
81
|
);
|
|
76
82
|
|
|
77
83
|
CREATE TABLE movies (
|
|
78
|
-
movieid
|
|
79
|
-
name
|
|
84
|
+
movieid INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
85
|
+
name VARCHAR(100) DEFAULT NULL,
|
|
80
86
|
PRIMARY KEY (movieid)
|
|
81
87
|
);
|
|
82
88
|
|
|
83
89
|
CREATE TABLE subscribers (
|
|
84
|
-
nick
|
|
85
|
-
name
|
|
90
|
+
nick VARCHAR(100) NOT NULL,
|
|
91
|
+
name VARCHAR(100) DEFAULT NULL,
|
|
86
92
|
PRIMARY KEY (nick)
|
|
87
93
|
);
|
|
88
94
|
|
|
89
95
|
CREATE TABLE booleantests (
|
|
90
|
-
id
|
|
91
|
-
value
|
|
96
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
97
|
+
value INT DEFAULT NULL,
|
|
92
98
|
PRIMARY KEY (id)
|
|
93
99
|
);
|
|
94
100
|
|
|
95
101
|
CREATE TABLE auto_id_tests (
|
|
96
|
-
auto_id
|
|
97
|
-
value
|
|
102
|
+
auto_id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
103
|
+
value INT DEFAULT NULL,
|
|
98
104
|
PRIMARY KEY (auto_id)
|
|
99
105
|
);
|
|
100
106
|
|
|
101
107
|
CREATE TABLE entrants (
|
|
102
|
-
id
|
|
103
|
-
name
|
|
104
|
-
course_id
|
|
108
|
+
id INT NOT NULL PRIMARY KEY,
|
|
109
|
+
name VARCHAR(255) NOT NULL,
|
|
110
|
+
course_id INT NOT NULL
|
|
105
111
|
);
|
|
106
112
|
|
|
107
113
|
CREATE TABLE colnametests (
|
|
108
|
-
id
|
|
109
|
-
references
|
|
114
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
115
|
+
references INT NOT NULL,
|
|
110
116
|
PRIMARY KEY (id)
|
|
111
117
|
);
|
|
112
118
|
|
|
113
119
|
CREATE TABLE mixins (
|
|
114
|
-
id
|
|
115
|
-
parent_id
|
|
116
|
-
pos
|
|
117
|
-
created_at
|
|
118
|
-
updated_at
|
|
119
|
-
lft
|
|
120
|
-
rgt
|
|
121
|
-
root_id
|
|
122
|
-
type
|
|
120
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
121
|
+
parent_id INT DEFAULT NULL,
|
|
122
|
+
pos INT DEFAULT NULL,
|
|
123
|
+
created_at TIMESTAMP DEFAULT NULL,
|
|
124
|
+
updated_at TIMESTAMP DEFAULT NULL,
|
|
125
|
+
lft INT DEFAULT NULL,
|
|
126
|
+
rgt INT DEFAULT NULL,
|
|
127
|
+
root_id INT DEFAULT NULL,
|
|
128
|
+
type VARCHAR(40) DEFAULT NULL,
|
|
123
129
|
PRIMARY KEY (id)
|
|
124
130
|
);
|
|
125
131
|
|
|
126
132
|
CREATE TABLE people (
|
|
127
|
-
id
|
|
128
|
-
first_name
|
|
129
|
-
lock_version
|
|
130
|
-
PRIMARY KEY
|
|
133
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
134
|
+
first_name VARCHAR(40) NOT NULL,
|
|
135
|
+
lock_version INT DEFAULT 0,
|
|
136
|
+
PRIMARY KEY (id)
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
CREATE TABLE readers (
|
|
140
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
141
|
+
post_id INT NOT NULL,
|
|
142
|
+
person_id INT NOT NULL,
|
|
143
|
+
PRIMARY KEY (id)
|
|
131
144
|
);
|
|
132
145
|
|
|
133
146
|
CREATE TABLE binaries (
|
|
134
|
-
id
|
|
135
|
-
data
|
|
136
|
-
PRIMARY KEY
|
|
147
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
148
|
+
data BLOB(50000),
|
|
149
|
+
PRIMARY KEY (id)
|
|
137
150
|
);
|
|
138
151
|
|
|
139
152
|
CREATE TABLE computers (
|
|
140
|
-
id
|
|
141
|
-
developer
|
|
142
|
-
extendedWarranty
|
|
153
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
154
|
+
developer INT NOT NULL,
|
|
155
|
+
extendedWarranty INT NOT NULL
|
|
143
156
|
);
|
|
144
157
|
|
|
145
158
|
CREATE TABLE posts (
|
|
146
|
-
id
|
|
147
|
-
author_id
|
|
148
|
-
title
|
|
149
|
-
type
|
|
150
|
-
body
|
|
159
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
160
|
+
author_id INT DEFAULT NULL,
|
|
161
|
+
title VARCHAR(255) DEFAULT NULL,
|
|
162
|
+
type VARCHAR(255) DEFAULT NULL,
|
|
163
|
+
body VARCHAR(3000) DEFAULT NULL
|
|
151
164
|
);
|
|
152
165
|
|
|
153
166
|
CREATE TABLE comments (
|
|
154
|
-
id
|
|
155
|
-
post_id
|
|
156
|
-
type
|
|
157
|
-
body
|
|
167
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
168
|
+
post_id INT DEFAULT NULL,
|
|
169
|
+
type VARCHAR(255) DEFAULT NULL,
|
|
170
|
+
body VARCHAR(3000) DEFAULT NULL
|
|
158
171
|
);
|
|
159
172
|
|
|
160
173
|
CREATE TABLE authors (
|
|
161
|
-
id
|
|
162
|
-
name
|
|
174
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
175
|
+
name VARCHAR(255) DEFAULT NULL
|
|
163
176
|
);
|
|
164
177
|
|
|
165
178
|
CREATE TABLE tasks (
|
|
166
|
-
id
|
|
167
|
-
starting
|
|
168
|
-
ending
|
|
179
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
180
|
+
starting TIMESTAMP DEFAULT NULL,
|
|
181
|
+
ending TIMESTAMP DEFAULT NULL
|
|
169
182
|
);
|
|
170
183
|
|
|
171
184
|
CREATE TABLE categories (
|
|
172
|
-
id
|
|
173
|
-
name
|
|
174
|
-
type
|
|
185
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
186
|
+
name VARCHAR(255) NOT NULL,
|
|
187
|
+
type VARCHAR(40) DEFAULT NULL
|
|
175
188
|
);
|
|
176
189
|
|
|
177
190
|
CREATE TABLE categories_posts (
|
|
178
|
-
category_id
|
|
179
|
-
post_id
|
|
191
|
+
category_id INT NOT NULL,
|
|
192
|
+
post_id INT NOT NULL
|
|
180
193
|
);
|
|
181
194
|
|
|
182
195
|
CREATE TABLE keyboards (
|
|
183
|
-
key_number
|
|
196
|
+
key_number INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
184
197
|
name VARCHAR(255)
|
|
185
198
|
);
|
|
186
199
|
|
|
187
200
|
CREATE TABLE fk_test_has_pk (
|
|
188
|
-
id
|
|
201
|
+
id INT NOT NULL PRIMARY KEY
|
|
189
202
|
);
|
|
190
203
|
|
|
191
204
|
CREATE TABLE fk_test_has_fk (
|
|
192
|
-
id
|
|
193
|
-
fk_id
|
|
205
|
+
id INT NOT NULL PRIMARY KEY,
|
|
206
|
+
fk_id INT NOT NULL,
|
|
194
207
|
|
|
195
208
|
FOREIGN KEY (fk_id) REFERENCES fk_test_has_pk(id)
|
|
196
209
|
);
|
|
210
|
+
|
|
211
|
+
--This table has an altered lock_version column name
|
|
212
|
+
CREATE TABLE legacy_things (
|
|
213
|
+
id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
|
|
214
|
+
tps_report_number INT DEFAULT NULL,
|
|
215
|
+
version INT DEFAULT 0,
|
|
216
|
+
PRIMARY KEY (id)
|
|
217
|
+
);
|