composite_primary_keys 12.0.2 → 12.0.10

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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +880 -841
  3. data/README.rdoc +180 -179
  4. data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -0
  5. data/lib/composite_primary_keys/arel/sqlserver.rb +1 -3
  6. data/lib/composite_primary_keys/associations/association_scope.rb +68 -68
  7. data/lib/composite_primary_keys/associations/join_dependency.rb +103 -103
  8. data/lib/composite_primary_keys/associations/through_association.rb +2 -1
  9. data/lib/composite_primary_keys/attribute_methods/primary_key.rb +13 -0
  10. data/lib/composite_primary_keys/attribute_methods/read.rb +30 -30
  11. data/lib/composite_primary_keys/attribute_methods/write.rb +35 -35
  12. data/lib/composite_primary_keys/attribute_methods.rb +9 -9
  13. data/lib/composite_primary_keys/base.rb +141 -130
  14. data/lib/composite_primary_keys/composite_arrays.rb +0 -8
  15. data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +37 -17
  16. data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +44 -23
  17. data/lib/composite_primary_keys/core.rb +48 -48
  18. data/lib/composite_primary_keys/persistence.rb +82 -81
  19. data/lib/composite_primary_keys/reflection.rb +29 -29
  20. data/lib/composite_primary_keys/relation/batches.rb +1 -1
  21. data/lib/composite_primary_keys/relation/calculations.rb +81 -81
  22. data/lib/composite_primary_keys/relation/finder_methods.rb +235 -235
  23. data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +20 -20
  24. data/lib/composite_primary_keys/relation/query_methods.rb +42 -42
  25. data/lib/composite_primary_keys/relation/where_clause.rb +23 -23
  26. data/lib/composite_primary_keys/relation.rb +193 -118
  27. data/lib/composite_primary_keys/version.rb +8 -8
  28. data/lib/composite_primary_keys.rb +117 -118
  29. data/test/abstract_unit.rb +114 -113
  30. data/test/connections/databases.ci.yml +22 -19
  31. data/test/fixtures/article.rb +4 -0
  32. data/test/fixtures/articles.yml +4 -3
  33. data/test/fixtures/comment.rb +1 -3
  34. data/test/fixtures/comments.yml +10 -9
  35. data/test/fixtures/db_definitions/db2-create-tables.sql +112 -126
  36. data/test/fixtures/db_definitions/db2-drop-tables.sql +17 -19
  37. data/test/fixtures/db_definitions/mysql.sql +180 -217
  38. data/test/fixtures/db_definitions/oracle.drop.sql +42 -48
  39. data/test/fixtures/db_definitions/oracle.sql +200 -236
  40. data/test/fixtures/db_definitions/postgresql.sql +183 -220
  41. data/test/fixtures/db_definitions/sqlite.sql +170 -206
  42. data/test/fixtures/db_definitions/sqlserver.sql +176 -212
  43. data/test/fixtures/department.rb +16 -11
  44. data/test/fixtures/departments.yml +15 -15
  45. data/test/fixtures/employees.yml +27 -27
  46. data/test/fixtures/readings.yml +2 -2
  47. data/test/fixtures/restaurants_suburbs.yml +11 -11
  48. data/test/fixtures/streets.yml +16 -16
  49. data/test/fixtures/suburbs.yml +14 -14
  50. data/test/fixtures/user.rb +11 -10
  51. data/test/test_associations.rb +358 -351
  52. data/test/test_attributes.rb +60 -60
  53. data/test/test_calculations.rb +42 -42
  54. data/test/test_create.rb +218 -183
  55. data/test/test_delete.rb +182 -179
  56. data/test/test_exists.rb +39 -39
  57. data/test/test_find.rb +164 -145
  58. data/test/test_habtm.rb +2 -2
  59. data/test/test_ids.rb +112 -116
  60. data/test/test_nested_attributes.rb +67 -124
  61. data/test/test_polymorphic.rb +29 -13
  62. data/test/test_preload.rb +4 -3
  63. data/test/test_serialize.rb +2 -2
  64. data/test/test_update.rb +96 -78
  65. metadata +4 -19
  66. data/test/fixtures/hack.rb +0 -5
  67. data/test/fixtures/hacks.yml +0 -3
  68. data/test/fixtures/pk_called_id.rb +0 -5
  69. data/test/fixtures/pk_called_ids.yml +0 -11
  70. data/test/fixtures/reference_code_using_composite_key_alias.rb +0 -8
  71. data/test/fixtures/reference_code_using_simple_key_alias.rb +0 -8
  72. data/test/fixtures/seat.rb +0 -5
  73. data/test/fixtures/seats.yml +0 -9
  74. data/test/fixtures/topic.rb +0 -6
  75. data/test/fixtures/topic_source.rb +0 -7
  76. data/test/test_aliases.rb +0 -18
  77. data/test/test_enum.rb +0 -21
  78. data/test/test_suite.rb +0 -35
@@ -1,113 +1,114 @@
1
- spec_name = ENV['ADAPTER'] || 'sqlite'
2
- require 'bundler/setup'
3
- require 'minitest/autorun'
4
-
5
- Bundler.require(:default, spec_name.to_sym)
6
- require 'composite_primary_keys'
7
-
8
- # Require the connection spec
9
- PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
10
- require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
11
-
12
- spec = CompositePrimaryKeys::ConnectionSpec[spec_name]
13
- puts "Loaded #{spec_name}"
14
-
15
- # And now connect to the database
16
- ActiveRecord::Base.establish_connection(spec)
17
-
18
- # Tell active record about the configuration
19
- ActiveRecord::Base.configurations = {test: spec}
20
-
21
- # Tell ActiveRecord where to find models
22
- ActiveSupport::Dependencies.autoload_paths << File.join(PROJECT_ROOT, 'test', 'fixtures')
23
-
24
- I18n.config.enforce_available_locales = true
25
-
26
- class ActiveSupport::TestCase
27
- include ActiveRecord::TestFixtures
28
-
29
- self.fixture_path = File.dirname(__FILE__) + '/fixtures/'
30
- self.use_instantiated_fixtures = false
31
- self.use_transactional_tests = true
32
- self.test_order = :random
33
-
34
- def assert_date_from_db(expected, actual, message = nil)
35
- # SQL Server doesn't have a separate column type just for dates,
36
- # so the time is in the string and incorrectly formatted
37
- if current_adapter?(:SQLServerAdapter)
38
- assert_equal expected.strftime('%Y/%m/%d 00:00:00'), actual.strftime('%Y/%m/%d 00:00:00')
39
- elsif current_adapter?(:SybaseAdapter)
40
- assert_equal expected.to_s, actual.to_date.to_s, message
41
- else
42
- assert_equal expected.to_s, actual.to_s, message
43
- end
44
- end
45
-
46
- def assert_queries(num = 1)
47
- ActiveRecord::Base.connection.class.class_eval do
48
- self.query_count = 0
49
- alias_method :execute, :execute_with_query_counting
50
- end
51
- yield
52
- ensure
53
- ActiveRecord::Base.connection.class.class_eval do
54
- alias_method :execute, :execute_without_query_counting
55
- end
56
- assert_equal num, ActiveRecord::Base.connection.query_count, '#{ActiveRecord::Base.connection.query_count} instead of #{num} queries were executed.'
57
- end
58
-
59
- def assert_no_queries(&block)
60
- assert_queries(0, &block)
61
- end
62
-
63
- cattr_accessor :classes
64
-
65
- protected
66
-
67
- def testing_with(&block)
68
- classes.keys.each do |key_test|
69
- @key_test = key_test
70
- @klass_info = classes[@key_test]
71
- @klass, @primary_keys = @klass_info[:class], @klass_info[:primary_keys]
72
- order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')
73
- @first = @klass.order(order).first
74
- yield
75
- end
76
- end
77
-
78
- def first_id
79
- ids = (1..@primary_keys.length).map {|num| 1}
80
- composite? ? ids.to_composite_ids : ids.first
81
- end
82
-
83
- def composite?
84
- @key_test != :single
85
- end
86
-
87
- # Oracle metadata is in all caps.
88
- def with_quoted_identifiers(s)
89
- s.gsub(/'(\w+)'/) { |m|
90
- if ActiveRecord::Base.configurations[:test]['adapter'] =~ /oracle/i
91
- m.upcase
92
- else
93
- m
94
- end
95
- }
96
- end
97
- end
98
-
99
- def current_adapter?(type)
100
- ActiveRecord::ConnectionAdapters.const_defined?(type) &&
101
- ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type))
102
- end
103
-
104
- ActiveRecord::Base.connection.class.class_eval do
105
- cattr_accessor :query_count
106
- alias_method :execute_without_query_counting, :execute
107
- def execute_with_query_counting(sql, name = nil)
108
- self.query_count += 1
109
- execute_without_query_counting(sql, name)
110
- end
111
- end
112
-
113
- ActiveRecord::Base.logger = Logger.new(ENV['CPK_LOGFILE'] || STDOUT)
1
+ spec_name = ENV['ADAPTER'] || 'sqlite'
2
+ require 'bundler'
3
+ require 'minitest/autorun'
4
+
5
+ Bundler.setup(:default, spec_name.to_sym)
6
+ Bundler.require(:default, spec_name.to_sym)
7
+ require 'composite_primary_keys'
8
+
9
+ # Require the connection spec
10
+ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
11
+ require File.join(PROJECT_ROOT, 'test', 'connections', 'connection_spec')
12
+
13
+ spec = CompositePrimaryKeys::ConnectionSpec[spec_name]
14
+ puts "Loaded #{spec_name}"
15
+
16
+ # And now connect to the database
17
+ ActiveRecord::Base.establish_connection(spec)
18
+
19
+ # Tell active record about the configuration
20
+ ActiveRecord::Base.configurations = {test: spec}
21
+
22
+ # Tell ActiveRecord where to find models
23
+ ActiveSupport::Dependencies.autoload_paths << File.join(PROJECT_ROOT, 'test', 'fixtures')
24
+
25
+ I18n.config.enforce_available_locales = true
26
+
27
+ class ActiveSupport::TestCase
28
+ include ActiveRecord::TestFixtures
29
+
30
+ self.fixture_path = File.dirname(__FILE__) + '/fixtures/'
31
+ self.use_instantiated_fixtures = false
32
+ self.use_transactional_tests = true
33
+ self.test_order = :random
34
+
35
+ def assert_date_from_db(expected, actual, message = nil)
36
+ # SQL Server doesn't have a separate column type just for dates,
37
+ # so the time is in the string and incorrectly formatted
38
+ if current_adapter?(:SQLServerAdapter)
39
+ assert_equal expected.strftime('%Y/%m/%d 00:00:00'), actual.strftime('%Y/%m/%d 00:00:00')
40
+ elsif current_adapter?(:SybaseAdapter)
41
+ assert_equal expected.to_s, actual.to_date.to_s, message
42
+ else
43
+ assert_equal expected.to_s, actual.to_s, message
44
+ end
45
+ end
46
+
47
+ def assert_queries(num = 1)
48
+ ActiveRecord::Base.connection.class.class_eval do
49
+ self.query_count = 0
50
+ alias_method :execute, :execute_with_query_counting
51
+ end
52
+ yield
53
+ ensure
54
+ ActiveRecord::Base.connection.class.class_eval do
55
+ alias_method :execute, :execute_without_query_counting
56
+ end
57
+ assert_equal num, ActiveRecord::Base.connection.query_count, '#{ActiveRecord::Base.connection.query_count} instead of #{num} queries were executed.'
58
+ end
59
+
60
+ def assert_no_queries(&block)
61
+ assert_queries(0, &block)
62
+ end
63
+
64
+ cattr_accessor :classes
65
+
66
+ protected
67
+
68
+ def testing_with(&block)
69
+ classes.keys.each do |key_test|
70
+ @key_test = key_test
71
+ @klass_info = classes[@key_test]
72
+ @klass, @primary_keys = @klass_info[:class], @klass_info[:primary_keys]
73
+ order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')
74
+ @first = @klass.order(order).first
75
+ yield
76
+ end
77
+ end
78
+
79
+ def first_id
80
+ ids = (1..@primary_keys.length).map {|num| 1}
81
+ composite? ? ids.to_composite_ids : ids.first
82
+ end
83
+
84
+ def composite?
85
+ @key_test != :single
86
+ end
87
+
88
+ # Oracle metadata is in all caps.
89
+ def with_quoted_identifiers(s)
90
+ s.gsub(/'(\w+)'/) { |m|
91
+ if ActiveRecord::Base.configurations[:test]['adapter'] =~ /oracle/i
92
+ m.upcase
93
+ else
94
+ m
95
+ end
96
+ }
97
+ end
98
+ end
99
+
100
+ def current_adapter?(type)
101
+ ActiveRecord::ConnectionAdapters.const_defined?(type) &&
102
+ ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type))
103
+ end
104
+
105
+ ActiveRecord::Base.connection.class.class_eval do
106
+ cattr_accessor :query_count
107
+ alias_method :execute_without_query_counting, :execute
108
+ def execute_with_query_counting(sql, name = nil)
109
+ self.query_count += 1
110
+ execute_without_query_counting(sql, name)
111
+ end
112
+ end
113
+
114
+ ActiveRecord::Base.logger = Logger.new(ENV['CPK_LOGFILE'] || STDOUT)
@@ -1,19 +1,22 @@
1
- mysql:
2
- adapter: mysql2
3
- username: travis
4
- password: ""
5
- encoding: utf8mb4
6
- charset: utf8mb4
7
- collation: utf8mb4_bin
8
- database: composite_primary_keys_unittest
9
-
10
- postgresql:
11
- adapter: postgresql
12
- database: composite_primary_keys_unittest
13
- username: postgres
14
- host: localhost
15
-
16
- sqlite:
17
- adapter: sqlite3
18
- database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
19
-
1
+ mysql:
2
+ adapter: mysql2
3
+ username: github
4
+ password: github
5
+ host: 127.0.0.1
6
+ port: 3306
7
+ encoding: utf8mb4
8
+ charset: utf8mb4
9
+ collation: utf8mb4_bin
10
+ database: composite_primary_keys_unittest
11
+
12
+ postgresql:
13
+ adapter: postgresql
14
+ database: composite_primary_keys_unittest
15
+ username: postgres
16
+ password: postgres
17
+ host: localhost
18
+
19
+ sqlite:
20
+ adapter: sqlite3
21
+ database: <%= File.join(project_root, 'db', 'composite_primary_keys_unittest.sqlite') %>
22
+
@@ -2,5 +2,9 @@ class Article < ActiveRecord::Base
2
2
  validates :id, uniqueness: true, numericality: true, allow_nil: true, allow_blank: true, on: :create
3
3
  has_many :readings, :dependent => :delete_all
4
4
  has_many :users, :through => :readings
5
+
6
+ has_many :comments, :dependent => :delete_all
7
+ has_many :employee_commentators, :through => :comments, :source => :person, :source_type => :employee
8
+ has_many :user_commentators, :through => :comments, :source => :person, :source_type => "User"
5
9
  end
6
10
 
@@ -1,7 +1,8 @@
1
1
  first:
2
- id: 1
3
2
  name: Article One
4
3
 
5
4
  second:
6
- id: 2
7
- name: Article Two
5
+ name: Article Two
6
+
7
+ third:
8
+ name: Article Three
@@ -1,7 +1,5 @@
1
1
  class Comment < ActiveRecord::Base
2
2
  belongs_to :person, :polymorphic => true
3
- belongs_to :hack
4
-
5
- enum :shown => [ :true, :false ]
3
+ belongs_to :article
6
4
  end
7
5
 
@@ -1,16 +1,17 @@
1
- comment1:
1
+ employee_comment:
2
2
  id: 1
3
+ article: first
3
4
  person_id: 1
4
5
  person_type: Employee
5
-
6
- comment2:
6
+
7
+ user_comment_1:
7
8
  id: 2
9
+ article: second
8
10
  person_id: 1
9
11
  person_type: User
10
- hack_id: 7
11
-
12
- comment3:
12
+
13
+ user_comment_2:
13
14
  id: 3
14
- person_id: 7
15
- person_type: Hack
16
-
15
+ article: second
16
+ person_id: 2
17
+ person_type: User
@@ -1,126 +1,112 @@
1
- CREATE TABLE topics (
2
- id integer NOT NULL,
3
- name varchar(50) default NULL,
4
- feed_size integer default NULL,
5
- PRIMARY KEY (id)
6
- );
7
-
8
- CREATE TABLE topic_sources (
9
- topic_id integer NOT NULL,
10
- platform varchar(50) NOT NULL,
11
- keywords varchar(50) default NULL,
12
- PRIMARY KEY (topic_id,platform)
13
- );
14
-
15
- CREATE TABLE reference_types (
16
- reference_type_id integer NOT NULL generated by default as identity (start with 100, increment by 1, no cache),
17
- type_label varchar(50) default NULL,
18
- abbreviation varchar(50) default NULL,
19
- description varchar(50) default NULL,
20
- PRIMARY KEY (reference_type_id)
21
- );
22
-
23
- CREATE TABLE reference_codes (
24
- reference_type_id integer,
25
- reference_code integer NOT NULL,
26
- code_label varchar(50) default NULL,
27
- abbreviation varchar(50) default NULL,
28
- description varchar(50) default NULL,
29
- PRIMARY KEY (reference_type_id,reference_code)
30
- );
31
-
32
- CREATE TABLE products (
33
- id integer NOT NULL,
34
- name varchar(50) default NULL,
35
- PRIMARY KEY (id)
36
- );
37
-
38
- CREATE TABLE tariffs (
39
- tariff_id integer NOT NULL,
40
- start_date date NOT NULL,
41
- amount integer default NULL,
42
- PRIMARY KEY (tariff_id,start_date)
43
- );
44
-
45
- CREATE TABLE product_tariffs (
46
- product_id integer NOT NULL,
47
- tariff_id integer NOT NULL,
48
- tariff_start_date date NOT NULL,
49
- PRIMARY KEY (product_id,tariff_id,tariff_start_date)
50
- );
51
-
52
- CREATE TABLE suburbs (
53
- city_id integer NOT NULL,
54
- suburb_id integer NOT NULL,
55
- name varchar(50) NOT NULL,
56
- PRIMARY KEY (city_id,suburb_id)
57
- );
58
-
59
- CREATE TABLE streets (
60
- id integer NOT NULL ,
61
- city_id integer NOT NULL,
62
- suburb_id integer NOT NULL,
63
- name varchar(50) NOT NULL,
64
- PRIMARY KEY (id)
65
- );
66
-
67
- CREATE TABLE users (
68
- id integer NOT NULL ,
69
- name varchar(50) NOT NULL,
70
- PRIMARY KEY (id)
71
- );
72
-
73
- CREATE TABLE articles (
74
- id integer NOT NULL ,
75
- name varchar(50) NOT NULL,
76
- PRIMARY KEY (id)
77
- );
78
-
79
- CREATE TABLE readings (
80
- id integer NOT NULL ,
81
- user_id integer NOT NULL,
82
- article_id integer NOT NULL,
83
- rating integer NOT NULL,
84
- PRIMARY KEY (id)
85
- );
86
-
87
- CREATE TABLE groups (
88
- id integer NOT NULL ,
89
- name varchar(50) NOT NULL,
90
- PRIMARY KEY (id)
91
- );
92
-
93
- CREATE TABLE memberships (
94
- user_id integer NOT NULL,
95
- group_id integer NOT NULL,
96
- PRIMARY KEY (user_id,group_id)
97
- );
98
-
99
- CREATE TABLE membership_statuses (
100
- id integer NOT NULL ,
101
- user_id integer NOT NULL,
102
- group_id integer NOT NULL,
103
- status varchar(50) NOT NULL,
104
- PRIMARY KEY (id)
105
- );
106
-
107
- create table restaurants (
108
- franchise_id integer not null,
109
- store_id integer not null,
110
- name varchar(100),
111
- lock_version integer default 0,
112
- primary key (franchise_id, store_id)
113
- );
114
-
115
- create table restaurants_suburbs (
116
- franchise_id integer not null,
117
- store_id integer not null,
118
- city_id integer not null,
119
- suburb_id integer not null
120
- );
121
-
122
- create table products_restaurants (
123
- product_id integer not null,
124
- franchise_id integer not null,
125
- store_id integer not null
126
- );
1
+ CREATE TABLE reference_types (
2
+ reference_type_id integer NOT NULL generated by default as identity (start with 100, increment by 1, no cache),
3
+ type_label varchar(50) default NULL,
4
+ abbreviation varchar(50) default NULL,
5
+ description varchar(50) default NULL,
6
+ PRIMARY KEY (reference_type_id)
7
+ );
8
+
9
+ CREATE TABLE reference_codes (
10
+ reference_type_id integer,
11
+ reference_code integer NOT NULL,
12
+ code_label varchar(50) default NULL,
13
+ abbreviation varchar(50) default NULL,
14
+ description varchar(50) default NULL,
15
+ PRIMARY KEY (reference_type_id,reference_code)
16
+ );
17
+
18
+ CREATE TABLE products (
19
+ id integer NOT NULL,
20
+ name varchar(50) default NULL,
21
+ PRIMARY KEY (id)
22
+ );
23
+
24
+ CREATE TABLE tariffs (
25
+ tariff_id integer NOT NULL,
26
+ start_date date NOT NULL,
27
+ amount integer default NULL,
28
+ PRIMARY KEY (tariff_id,start_date)
29
+ );
30
+
31
+ CREATE TABLE product_tariffs (
32
+ product_id integer NOT NULL,
33
+ tariff_id integer NOT NULL,
34
+ tariff_start_date date NOT NULL,
35
+ PRIMARY KEY (product_id,tariff_id,tariff_start_date)
36
+ );
37
+
38
+ CREATE TABLE suburbs (
39
+ city_id integer NOT NULL,
40
+ suburb_id integer NOT NULL,
41
+ name varchar(50) NOT NULL,
42
+ PRIMARY KEY (city_id,suburb_id)
43
+ );
44
+
45
+ CREATE TABLE streets (
46
+ id integer NOT NULL ,
47
+ city_id integer NOT NULL,
48
+ suburb_id integer NOT NULL,
49
+ name varchar(50) NOT NULL,
50
+ PRIMARY KEY (id)
51
+ );
52
+
53
+ CREATE TABLE users (
54
+ id integer NOT NULL ,
55
+ name varchar(50) NOT NULL,
56
+ PRIMARY KEY (id)
57
+ );
58
+
59
+ CREATE TABLE articles (
60
+ id integer NOT NULL ,
61
+ name varchar(50) NOT NULL,
62
+ PRIMARY KEY (id)
63
+ );
64
+
65
+ CREATE TABLE readings (
66
+ id integer NOT NULL ,
67
+ user_id integer NOT NULL,
68
+ article_id integer NOT NULL,
69
+ rating integer NOT NULL,
70
+ PRIMARY KEY (id)
71
+ );
72
+
73
+ CREATE TABLE groups (
74
+ id integer NOT NULL ,
75
+ name varchar(50) NOT NULL,
76
+ PRIMARY KEY (id)
77
+ );
78
+
79
+ CREATE TABLE memberships (
80
+ user_id integer NOT NULL,
81
+ group_id integer NOT NULL,
82
+ PRIMARY KEY (user_id,group_id)
83
+ );
84
+
85
+ CREATE TABLE membership_statuses (
86
+ id integer NOT NULL ,
87
+ user_id integer NOT NULL,
88
+ group_id integer NOT NULL,
89
+ status varchar(50) NOT NULL,
90
+ PRIMARY KEY (id)
91
+ );
92
+
93
+ create table restaurants (
94
+ franchise_id integer not null,
95
+ store_id integer not null,
96
+ name varchar(100),
97
+ lock_version integer default 0,
98
+ primary key (franchise_id, store_id)
99
+ );
100
+
101
+ create table restaurants_suburbs (
102
+ franchise_id integer not null,
103
+ store_id integer not null,
104
+ city_id integer not null,
105
+ suburb_id integer not null
106
+ );
107
+
108
+ create table products_restaurants (
109
+ product_id integer not null,
110
+ franchise_id integer not null,
111
+ store_id integer not null
112
+ );
@@ -1,19 +1,17 @@
1
- drop table MEMBERSHIPS;
2
- drop table REFERENCE_CODES;
3
- drop table TARIFFS;
4
- drop table ARTICLES;
5
- drop table GROUPS;
6
- drop table MEMBERSHIP_STATUSES;
7
- drop table READINGS;
8
- drop table REFERENCE_TYPES;
9
- drop table STREETS;
10
- drop table PRODUCTS;
11
- drop table USERS;
12
- drop table SUBURBS;
13
- drop table PRODUCT_TARIFFS;
14
- drop table KITCHEN_SINK;
15
- drop table RESTAURANTS;
16
- drop table RESTAURANTS_SUBURBS;
17
- drop table PRODUCTS_RESTAURANTS;
18
- drop table TOPICS;
19
- drop table TOPIC_SOURCES;
1
+ drop table MEMBERSHIPS;
2
+ drop table REFERENCE_CODES;
3
+ drop table TARIFFS;
4
+ drop table ARTICLES;
5
+ drop table GROUPS;
6
+ drop table MEMBERSHIP_STATUSES;
7
+ drop table READINGS;
8
+ drop table REFERENCE_TYPES;
9
+ drop table STREETS;
10
+ drop table PRODUCTS;
11
+ drop table USERS;
12
+ drop table SUBURBS;
13
+ drop table PRODUCT_TARIFFS;
14
+ drop table KITCHEN_SINK;
15
+ drop table RESTAURANTS;
16
+ drop table RESTAURANTS_SUBURBS;
17
+ drop table PRODUCTS_RESTAURANTS;