composite_primary_keys 8.1.6 → 9.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +5 -5
  2. data/History.rdoc +59 -7
  3. data/README.rdoc +62 -1
  4. data/Rakefile +4 -1
  5. data/lib/composite_primary_keys/arel/in.rb +6 -0
  6. data/lib/composite_primary_keys/arel/sqlserver.rb +36 -0
  7. data/lib/composite_primary_keys/arel/to_sql.rb +26 -0
  8. data/lib/composite_primary_keys/associations/association.rb +14 -12
  9. data/lib/composite_primary_keys/associations/association_scope.rb +22 -27
  10. data/lib/composite_primary_keys/associations/collection_association.rb +39 -8
  11. data/lib/composite_primary_keys/associations/has_many_association.rb +17 -40
  12. data/lib/composite_primary_keys/associations/has_many_through_association.rb +58 -58
  13. data/lib/composite_primary_keys/associations/join_dependency/join_association.rb +13 -11
  14. data/lib/composite_primary_keys/associations/join_dependency.rb +73 -56
  15. data/lib/composite_primary_keys/associations/preloader/association.rb +75 -73
  16. data/lib/composite_primary_keys/attribute_methods/primary_key.rb +13 -11
  17. data/lib/composite_primary_keys/attribute_methods/read.rb +18 -15
  18. data/lib/composite_primary_keys/attribute_methods/write.rb +21 -19
  19. data/lib/composite_primary_keys/attribute_methods.rb +6 -4
  20. data/lib/composite_primary_keys/autosave_association.rb +19 -54
  21. data/lib/composite_primary_keys/base.rb +18 -82
  22. data/lib/composite_primary_keys/composite_arrays.rb +9 -1
  23. data/lib/composite_primary_keys/composite_predicates.rb +1 -0
  24. data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +10 -10
  25. data/lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb +5 -6
  26. data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +23 -0
  27. data/lib/composite_primary_keys/core.rb +46 -45
  28. data/lib/composite_primary_keys/fixtures.rb +19 -17
  29. data/lib/composite_primary_keys/locking/optimistic.rb +53 -49
  30. data/lib/composite_primary_keys/nested_attributes.rb +60 -53
  31. data/lib/composite_primary_keys/persistence.rb +49 -41
  32. data/lib/composite_primary_keys/relation/batches.rb +35 -32
  33. data/lib/composite_primary_keys/relation/calculations.rb +3 -7
  34. data/lib/composite_primary_keys/relation/finder_methods.rb +122 -55
  35. data/lib/composite_primary_keys/relation/predicate_builder.rb +18 -29
  36. data/lib/composite_primary_keys/relation/query_methods.rb +25 -36
  37. data/lib/composite_primary_keys/relation/where_clause.rb +33 -0
  38. data/lib/composite_primary_keys/relation.rb +96 -43
  39. data/lib/composite_primary_keys/sanitization.rb +6 -15
  40. data/lib/composite_primary_keys/version.rb +3 -3
  41. data/lib/composite_primary_keys.rb +10 -19
  42. data/scripts/console.rb +48 -48
  43. data/scripts/txt2html +76 -76
  44. data/scripts/txt2js +65 -65
  45. data/tasks/databases/mysql.rake +17 -19
  46. data/tasks/databases/oracle.rake +29 -15
  47. data/tasks/databases/postgresql.rake +20 -29
  48. data/tasks/databases/sqlite.rake +25 -0
  49. data/tasks/databases/sqlserver.rake +32 -16
  50. data/tasks/website.rake +18 -18
  51. data/test/README_tests.rdoc +56 -56
  52. data/test/abstract_unit.rb +24 -18
  53. data/test/connections/connection_spec.rb +11 -2
  54. data/test/connections/databases.ci.yml +5 -4
  55. data/test/connections/databases.example.yml +19 -4
  56. data/test/connections/databases.yml +40 -30
  57. data/test/db_test.rb +52 -52
  58. data/test/fixtures/article.rb +1 -0
  59. data/test/fixtures/articles.yml +6 -6
  60. data/test/fixtures/capitol.rb +3 -3
  61. data/test/fixtures/capitols.yml +16 -16
  62. data/test/fixtures/comments.yml +15 -15
  63. data/test/fixtures/db_definitions/mysql.sql +16 -17
  64. data/test/fixtures/db_definitions/oracle.drop.sql +2 -0
  65. data/test/fixtures/db_definitions/oracle.sql +26 -17
  66. data/test/fixtures/db_definitions/postgresql.sql +2 -3
  67. data/test/fixtures/db_definitions/sqlite.sql +0 -1
  68. data/test/fixtures/db_definitions/sqlserver.sql +20 -35
  69. data/test/fixtures/department.rb +5 -5
  70. data/test/fixtures/departments.yml +15 -15
  71. data/test/fixtures/dorms.yml +4 -4
  72. data/test/fixtures/employee.rb +5 -7
  73. data/test/fixtures/employees.yml +1 -5
  74. data/test/fixtures/group.rb +2 -2
  75. data/test/fixtures/groups.yml +6 -6
  76. data/test/fixtures/hack.rb +4 -4
  77. data/test/fixtures/hacks.yml +2 -2
  78. data/test/fixtures/membership_status.rb +2 -2
  79. data/test/fixtures/product.rb +9 -9
  80. data/test/fixtures/product_tariff.rb +5 -5
  81. data/test/fixtures/products.yml +11 -11
  82. data/test/fixtures/reading.rb +4 -4
  83. data/test/fixtures/readings.yml +10 -10
  84. data/test/fixtures/reference_code_using_composite_key_alias.rb +8 -8
  85. data/test/fixtures/reference_code_using_simple_key_alias.rb +8 -8
  86. data/test/fixtures/reference_codes.yml +28 -28
  87. data/test/fixtures/reference_type.rb +1 -1
  88. data/test/fixtures/reference_types.yml +9 -9
  89. data/test/fixtures/restaurant.rb +9 -9
  90. data/test/fixtures/restaurants.yml +14 -14
  91. data/test/fixtures/restaurants_suburbs.yml +10 -10
  92. data/test/fixtures/room.rb +11 -11
  93. data/test/fixtures/room_assignment.rb +13 -13
  94. data/test/fixtures/room_assignments.yml +24 -24
  95. data/test/fixtures/room_attribute.rb +2 -2
  96. data/test/fixtures/room_attribute_assignment.rb +4 -4
  97. data/test/fixtures/room_attribute_assignments.yml +4 -4
  98. data/test/fixtures/room_attributes.yml +2 -2
  99. data/test/fixtures/rooms.yml +12 -12
  100. data/test/fixtures/seat.rb +5 -5
  101. data/test/fixtures/seats.yml +8 -8
  102. data/test/fixtures/street.rb +2 -2
  103. data/test/fixtures/streets.yml +16 -16
  104. data/test/fixtures/student.rb +3 -3
  105. data/test/fixtures/students.yml +15 -15
  106. data/test/fixtures/suburbs.yml +14 -14
  107. data/test/fixtures/tariff.rb +1 -1
  108. data/test/fixtures/tariffs.yml +14 -14
  109. data/test/fixtures/user.rb +0 -1
  110. data/test/plugins/pagination.rb +405 -405
  111. data/test/plugins/pagination_helper.rb +135 -135
  112. data/test/setup.rb +50 -50
  113. data/test/test_aliases.rb +18 -18
  114. data/test/test_associations.rb +18 -17
  115. data/test/test_composite_arrays.rb +24 -24
  116. data/test/test_counter_cache.rb +30 -30
  117. data/test/test_create.rb +14 -6
  118. data/test/test_delete.rb +36 -34
  119. data/test/test_dup.rb +37 -37
  120. data/test/test_exists.rb +39 -39
  121. data/test/test_find.rb +16 -4
  122. data/test/test_habtm.rb +27 -3
  123. data/test/test_miscellaneous.rb +32 -32
  124. data/test/test_nested_attributes.rb +6 -6
  125. data/test/test_pagination.rb +35 -35
  126. data/test/test_polymorphic.rb +0 -7
  127. data/test/test_predicates.rb +20 -20
  128. data/test/test_preload.rb +94 -0
  129. data/test/test_suite.rb +1 -1
  130. data/test/test_update.rb +10 -7
  131. data/test/test_validations.rb +13 -13
  132. metadata +30 -39
  133. data/README_DB2.rdoc +0 -33
  134. data/lib/composite_primary_keys/arel/visitors/to_sql.rb +0 -36
  135. data/lib/composite_primary_keys/associations/singular_association.rb +0 -18
  136. data/lib/composite_primary_keys/attribute_methods/dirty.rb +0 -29
  137. data/lib/composite_primary_keys/attribute_set/builder.rb +0 -20
  138. data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +0 -70
  139. data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +0 -19
  140. data/lib/composite_primary_keys/dirty.rb +0 -19
  141. data/lib/composite_primary_keys/validations/uniqueness.rb +0 -41
  142. data/tasks/databases/oracle_enhanced.rake +0 -27
  143. data/tasks/databases/sqlite3.rake +0 -27
  144. data/test/connections/native_ibm_db/connection.rb +0 -19
  145. data/test/connections/native_mysql/connection.rb +0 -17
  146. data/test/connections/native_oracle/connection.rb +0 -11
  147. data/test/connections/native_oracle_enhanced/connection.rb +0 -16
  148. data/test/connections/native_postgresql/connection.rb +0 -13
  149. data/test/connections/native_sqlite3/connection.rb +0 -9
  150. data/test/connections/native_sqlserver/connection.rb +0 -11
  151. data/test/fixtures/db_definitions/sqlserver.drop.sql +0 -92
  152. data/test/test_delete_all.rb +0 -35
  153. data/test/test_find_in_batches.rb +0 -30
@@ -1,17 +1,26 @@
1
1
  require 'yaml'
2
+ require 'erb'
2
3
 
3
4
  module CompositePrimaryKeys
4
5
  class ConnectionSpec
5
6
  def self.[](adapter)
6
- config[adapter.to_s]
7
+ config[adapter.to_s].dup
7
8
  end
8
9
 
9
10
  private
10
11
 
11
12
  def self.config
12
13
  @config ||= begin
14
+ # Find the file location
13
15
  path = File.join(PROJECT_ROOT, 'test', 'connections', 'databases.yml')
14
- YAML.load_file(path)
16
+
17
+ # Run any erb code
18
+ template = ERB.new(File.read(path))
19
+ project_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
20
+ data = template.result(binding)
21
+
22
+ # And now to YAML
23
+ YAML.load(data)
15
24
  end
16
25
  end
17
26
  end
@@ -4,12 +4,13 @@ mysql:
4
4
  password: ""
5
5
  database: composite_primary_keys_unittest
6
6
 
7
- sqlite3:
8
- adapter: sqlite3
9
- database: db/composite_primary_keys_unittest.sqlite
10
-
11
7
  postgresql:
12
8
  adapter: postgresql
13
9
  database: composite_primary_keys_unittest
14
10
  username: postgres
15
11
  host: localhost
12
+
13
+ sqlite:
14
+ adapter: sqlite3
15
+ database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
16
+
@@ -2,14 +2,24 @@
2
2
  # 1. Copy this file to test/connections/databases.yml.
3
3
  # 2. Update to match the databases you want to test against.
4
4
 
5
+ ibm_db:
6
+ database: ocdpdev
7
+ username: db2inst1
8
+ password: password
9
+ host: localhost
10
+
5
11
  mysql:
6
12
  adapter: mysql2
7
13
  username: root
14
+ password: mysql
8
15
  database: composite_primary_keys_unittest
9
16
 
10
- sqlite3:
11
- adapter: sqlite3
12
- database: db/composite_primary_keys_unittest.sqlite
17
+ oracle:
18
+ adapter: oracle_enhanced
19
+ database: xe
20
+ username: SYSTEM
21
+ password: oracle
22
+ host: localhost
13
23
 
14
24
  postgresql:
15
25
  adapter: postgresql
@@ -17,9 +27,14 @@ postgresql:
17
27
  username: postgres
18
28
  host: localhost
19
29
 
30
+ sqlite:
31
+ adapter: sqlite3
32
+ database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
33
+
20
34
  sqlserver:
21
35
  adapter: sqlserver
36
+ username: cpk
37
+ password: cpk
22
38
  database: composite_primary_keys_unittest
23
- username: rails
24
39
  host: localhost
25
40
  port: 1433
@@ -1,30 +1,40 @@
1
- mysql:
2
- adapter: mysql2
3
- username: root
4
- password: mysql
5
- database: composite_primary_keys_unittest
6
-
7
- oracle:
8
- adapter: oracle_enhanced
9
- database: xe
10
- username: SYSTEM
11
- password: oracle
12
- host: localhost
13
-
14
- postgresql:
15
- adapter: postgresql
16
- database: composite_primary_keys_unittest
17
- username: postgres
18
- host: localhost
19
-
20
- sqlite:
21
- adapter: sqlite3
22
- database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
23
-
24
- sqlserver:
25
- adapter: sqlserver
26
- username: cpk
27
- password: cpk
28
- database: composite_primary_keys_unittest
29
- host: localhost
30
- port: 1433
1
+ # To run tests:
2
+ # 1. Copy this file to test/connections/databases.yml.
3
+ # 2. Update to match the databases you want to test against.
4
+
5
+ ibm_db:
6
+ database: ocdpdev
7
+ username: db2inst1
8
+ password: password
9
+ host: localhost
10
+
11
+ mysql:
12
+ adapter: mysql2
13
+ username: root
14
+ password: mysql
15
+ database: composite_primary_keys_unittest
16
+
17
+ oracle:
18
+ adapter: oracle_enhanced
19
+ database: xe
20
+ username: SYSTEM
21
+ password: oracle
22
+ host: localhost
23
+
24
+ postgresql:
25
+ adapter: postgresql
26
+ database: composite_primary_keys_unittest
27
+ username: postgres
28
+ host: localhost
29
+
30
+ sqlite:
31
+ adapter: sqlite3
32
+ database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
33
+
34
+ sqlserver:
35
+ adapter: sqlserver
36
+ username: cpk
37
+ password: cpk
38
+ database: composite_primary_keys_unittest
39
+ host: localhost
40
+ port: 1433
data/test/db_test.rb CHANGED
@@ -1,53 +1,53 @@
1
- # assoc_test.rb
2
-
3
- path = File.expand_path(File.join(File.basename(__FILE__), "..", "lib", "composite_primary_keys"))
4
- puts path
5
-
6
- require File.join(path)
7
- require 'active_record'
8
-
9
- $configuration = {
10
- :adapter => 'postgresql',
11
- :database => 'cpk_test',
12
- :username => 'postgres'
13
- }
14
-
15
- ActiveRecord::Base.establish_connection($configuration) unless ActiveRecord::Base.connected?
16
-
17
- module GlobePG
18
- class PGBase < ActiveRecord::Base
19
- self.abstract_class = true
20
- # establish_connection($configuration) unless connected?
21
- end
22
- end
23
-
24
- module GlobePG
25
- class TeacherToSchool < PGBase
26
- set_table_name 'teacher_to_school'
27
- self.primary_keys = ['teacherid', 'schoolid']
28
-
29
- belongs_to :globe_teacher, :foreign_key => 'teacherid'
30
- belongs_to :globe_school, :foreign_key => 'schoolid'
31
- end
32
- end
33
-
34
- module GlobePG
35
- class GlobeSchool < PGBase
36
- set_table_name 'globe_school'
37
- self.primary_key = 'schoolid'
38
- has_many :teacher_to_schools, :foreign_key => :schoolid
39
- has_many :globe_teachers, :through => :teacher_to_schools
40
- end
41
- end
42
-
43
- module GlobePG
44
- class GlobeTeacher < PGBase
45
- set_table_name 'globe_teacher'
46
- self.primary_key = 'teacherid'
47
- has_many :teacher_to_schools, :foreign_key => :teacherid
48
- has_many :globe_schools, :through => :teacher_to_schools
49
- end
50
- end
51
-
52
- teacher = GlobePG::GlobeTeacher.find_by_teacherid('ZZGLOBEY')
1
+ # assoc_test.rb
2
+
3
+ path = File.expand_path(File.join(File.basename(__FILE__), "..", "lib", "composite_primary_keys"))
4
+ puts path
5
+
6
+ require File.join(path)
7
+ require 'active_record'
8
+
9
+ $configuration = {
10
+ :adapter => 'postgresql',
11
+ :database => 'cpk_test',
12
+ :username => 'postgres'
13
+ }
14
+
15
+ ActiveRecord::Base.establish_connection($configuration) unless ActiveRecord::Base.connected?
16
+
17
+ module GlobePG
18
+ class PGBase < ActiveRecord::Base
19
+ self.abstract_class = true
20
+ # establish_connection($configuration) unless connected?
21
+ end
22
+ end
23
+
24
+ module GlobePG
25
+ class TeacherToSchool < PGBase
26
+ set_table_name 'teacher_to_school'
27
+ self.primary_keys = ['teacherid', 'schoolid']
28
+
29
+ belongs_to :globe_teacher, :foreign_key => 'teacherid'
30
+ belongs_to :globe_school, :foreign_key => 'schoolid'
31
+ end
32
+ end
33
+
34
+ module GlobePG
35
+ class GlobeSchool < PGBase
36
+ set_table_name 'globe_school'
37
+ self.primary_key = 'schoolid'
38
+ has_many :teacher_to_schools, :foreign_key => :schoolid
39
+ has_many :globe_teachers, :through => :teacher_to_schools
40
+ end
41
+ end
42
+
43
+ module GlobePG
44
+ class GlobeTeacher < PGBase
45
+ set_table_name 'globe_teacher'
46
+ self.primary_key = 'teacherid'
47
+ has_many :teacher_to_schools, :foreign_key => :teacherid
48
+ has_many :globe_schools, :through => :teacher_to_schools
49
+ end
50
+ end
51
+
52
+ teacher = GlobePG::GlobeTeacher.find_by_teacherid('ZZGLOBEY')
53
53
  p teacher.globe_schools
@@ -1,4 +1,5 @@
1
1
  class Article < ActiveRecord::Base
2
+ validates :id, uniqueness: true, numericality: true, allow_nil: true, allow_blank: true, on: :create
2
3
  has_many :readings, :dependent => :delete_all
3
4
  has_many :users, :through => :readings
4
5
  end
@@ -1,7 +1,7 @@
1
- first:
2
- id: 1
3
- name: Article One
4
-
5
- second:
6
- id: 2
1
+ first:
2
+ id: 1
3
+ name: Article One
4
+
5
+ second:
6
+ id: 2
7
7
  name: Article Two
@@ -1,3 +1,3 @@
1
- class Capitol < ActiveRecord::Base
2
- self.primary_keys = :country, :city
3
- end
1
+ class Capitol < ActiveRecord::Base
2
+ self.primary_keys = :country, :city
3
+ end
@@ -1,16 +1,16 @@
1
- netherlands:
2
- country: The Netherlands
3
- city: Amsterdam
4
-
5
- france:
6
- country: France
7
- city: Paris
8
-
9
- canada:
10
- country: Canada
11
- city: Ottawa
12
-
13
- mexico:
14
- country: Mexico
15
- city: Mexico City
16
-
1
+ netherlands:
2
+ country: The Netherlands
3
+ city: Amsterdam
4
+
5
+ france:
6
+ country: France
7
+ city: Paris
8
+
9
+ canada:
10
+ country: Canada
11
+ city: Ottawa
12
+
13
+ mexico:
14
+ country: Mexico
15
+ city: Mexico City
16
+
@@ -1,16 +1,16 @@
1
- comment1:
2
- id: 1
3
- person_id: 1
4
- person_type: Employee
5
-
6
- comment2:
7
- id: 2
8
- person_id: 1
9
- person_type: User
10
- hack_id: 7
11
-
12
- comment3:
13
- id: 3
14
- person_id: 7
15
- person_type: Hack
1
+ comment1:
2
+ id: 1
3
+ person_id: 1
4
+ person_type: Employee
5
+
6
+ comment2:
7
+ id: 2
8
+ person_id: 1
9
+ person_type: User
10
+ hack_id: 7
11
+
12
+ comment3:
13
+ id: 3
14
+ person_id: 7
15
+ person_type: Hack
16
16
 
@@ -1,5 +1,5 @@
1
1
  create table topics (
2
- id int not null auto_increment,
2
+ id int not null auto_increment,
3
3
  name varchar(50) default null,
4
4
  feed_size int default null,
5
5
  primary key (id)
@@ -39,8 +39,8 @@ create table tariffs (
39
39
  tariff_id int not null,
40
40
  start_date date not null,
41
41
  amount integer(11) default null,
42
- created_at timestamp,
43
- updated_at timestamp,
42
+ created_at datetime,
43
+ updated_at datetime,
44
44
  primary key (tariff_id, start_date)
45
45
  );
46
46
 
@@ -116,7 +116,6 @@ create table employees (
116
116
  id int not null auto_increment,
117
117
  department_id int default null,
118
118
  location_id int default null,
119
- name varchar(100) not null default 'anonymous',
120
119
  primary key (id)
121
120
  );
122
121
 
@@ -156,8 +155,8 @@ create table restaurants (
156
155
  create table restaurants_suburbs (
157
156
  franchise_id int not null,
158
157
  store_id int not null,
159
- city_id int not null,
160
- suburb_id int not null
158
+ city_id int default null,
159
+ suburb_id int default null
161
160
  );
162
161
 
163
162
  create table dorms (
@@ -202,15 +201,15 @@ create table seats (
202
201
  );
203
202
 
204
203
  create table capitols (
205
- country varchar(100) default null,
206
- city varchar(100) default null,
204
+ country varchar(100) not null,
205
+ city varchar(100) not null,
207
206
  primary key (country, city)
208
207
  );
209
208
 
210
209
  create table products_restaurants (
211
210
  product_id int not null,
212
- franchise_id int not null,
213
- store_id int not null
211
+ franchise_id int default null,
212
+ store_id int default null
214
213
  );
215
214
 
216
215
  create table employees_groups (
@@ -219,10 +218,10 @@ create table employees_groups (
219
218
  );
220
219
 
221
220
  create table pk_called_ids (
222
- id serial not null,
223
- reference_code int not null,
224
- code_label varchar(50) default null,
225
- abbreviation varchar(50) default null,
226
- description varchar(50) default null,
227
- primary key (id, reference_code)
228
- );
221
+ id integer not null,
222
+ reference_code int not null,
223
+ code_label varchar(50) default null,
224
+ abbreviation varchar(50) default null,
225
+ description varchar(50) default null,
226
+ primary key (id, reference_code)
227
+ );
@@ -46,3 +46,5 @@ drop table seats;
46
46
  drop table capitols;
47
47
  drop table products_restaurants;
48
48
  drop table employees_groups;
49
+ drop table pk_called_ids;
50
+ drop sequence pk_called_ids_seq;
@@ -16,24 +16,24 @@ create sequence reference_types_seq start with 1000;
16
16
 
17
17
  create table reference_types (
18
18
  reference_type_id number(11) primary key,
19
- type_label varchar2(50) default null,
20
- abbreviation varchar2(50) default null,
21
- description varchar2(50) default null
19
+ type_label varchar(50) default null,
20
+ abbreviation varchar(50) default null,
21
+ description varchar(50) default null
22
22
  );
23
23
 
24
24
  create table reference_codes (
25
25
  reference_type_id number(11),
26
26
  reference_code number(11),
27
- code_label varchar2(50) default null,
28
- abbreviation varchar2(50) default null,
29
- description varchar2(50) default null
27
+ code_label varchar(50) default null,
28
+ abbreviation varchar(50) default null,
29
+ description varchar(50) default null
30
30
  );
31
31
 
32
32
  create sequence products_seq start with 1000;
33
33
 
34
34
  create table products (
35
35
  id number(11) primary key,
36
- name varchar2(50) default null
36
+ name varchar(50) default null
37
37
  );
38
38
 
39
39
  create table tariffs (
@@ -55,7 +55,7 @@ create table product_tariffs (
55
55
  create table suburbs (
56
56
  city_id number(11),
57
57
  suburb_id number(11),
58
- name varchar2(50) not null,
58
+ name varchar(50) not null,
59
59
  constraint suburbs_pk primary key (city_id, suburb_id)
60
60
  );
61
61
 
@@ -65,21 +65,21 @@ create table streets (
65
65
  id number(11) primary key,
66
66
  city_id number(11) not null,
67
67
  suburb_id number(11) not null,
68
- name varchar2(50) not null
68
+ name varchar(50) not null
69
69
  );
70
70
 
71
71
  create sequence users_seq start with 1000;
72
72
 
73
73
  create table users (
74
74
  id number(11) primary key,
75
- name varchar2(50) not null
75
+ name varchar(50) not null
76
76
  );
77
77
 
78
78
  create sequence articles_seq start with 1000;
79
79
 
80
80
  create table articles (
81
81
  id number(11) primary key,
82
- name varchar2(50) not null
82
+ name varchar(50) not null
83
83
  );
84
84
 
85
85
  create sequence readings_seq start with 1000;
@@ -95,7 +95,7 @@ create sequence groups_seq start with 1000;
95
95
 
96
96
  create table groups (
97
97
  id number(11) primary key,
98
- name varchar2(50) not null
98
+ name varchar(50) not null
99
99
  );
100
100
 
101
101
  create table memberships (
@@ -110,7 +110,7 @@ create table membership_statuses (
110
110
  id number(11) primary key,
111
111
  user_id number(11) not null,
112
112
  group_id number(11) not null,
113
- status varchar2(50) not null
113
+ status varchar(50) not null
114
114
  );
115
115
 
116
116
  create table departments (
@@ -124,8 +124,7 @@ create sequence employees_seq start with 1000;
124
124
  create table employees (
125
125
  id number(11) not null primary key,
126
126
  department_id number(11) default null,
127
- location_id number(11) default null,
128
- name varchar2(100) default 'anonymous'
127
+ location_id number(11) default null
129
128
  );
130
129
 
131
130
  create sequence salaries_seq start with 1000;
@@ -219,8 +218,8 @@ create table seats (
219
218
  );
220
219
 
221
220
  create table capitols (
222
- country varchar2(100) not null,
223
- city varchar2(100) not null,
221
+ country varchar(100) not null,
222
+ city varchar(100) not null,
224
223
  primary key (country, city)
225
224
  );
226
225
 
@@ -235,3 +234,13 @@ create table employees_groups (
235
234
  group_id int not null
236
235
  );
237
236
 
237
+ create sequence pk_called_ids_seq start with 1000;
238
+
239
+ create table pk_called_ids (
240
+ id int not null,
241
+ reference_code int not null,
242
+ code_label varchar(50) default null,
243
+ abbreviation varchar(50) default null,
244
+ description varchar(50) default null,
245
+ constraint pk_called_ids_pk primary key (id, reference_code)
246
+ );
@@ -41,9 +41,9 @@ create table tariffs (
41
41
  tariff_id int not null,
42
42
  start_date date not null,
43
43
  amount int default null,
44
- primary key (tariff_id, start_date),
45
44
  created_at timestamp without time zone NOT NULL,
46
- updated_at timestamp without time zone NOT NULL
45
+ updated_at timestamp without time zone NOT NULL,
46
+ primary key (tariff_id, start_date)
47
47
  );
48
48
 
49
49
  create table product_tariffs (
@@ -118,7 +118,6 @@ create table employees (
118
118
  id serial not null,
119
119
  department_id int default null,
120
120
  location_id int default null,
121
- name text not null default 'anonymous',
122
121
  primary key (id)
123
122
  );
124
123
 
@@ -109,7 +109,6 @@ create table departments (
109
109
  create table employees (
110
110
  id integer not null primary key autoincrement,
111
111
  department_id integer null,
112
- name text not null default 'anonymous',
113
112
  location_id integer null
114
113
  );
115
114