pact_broker 2.0.0.beta.1 → 2.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -1
  3. data/config/database.yml +7 -0
  4. data/db/migrations/{23_create_pact_contents_table.rb → 23_create_pact_versions_table.rb} +2 -2
  5. data/db/migrations/24_populate_pact_versions.rb +8 -0
  6. data/db/migrations/{26_make_pc_pacticipants_mandatory.rb → 25_make_pv_pacticipants_mandatory.rb} +1 -1
  7. data/db/migrations/{27_create_pact_publications.rb → 26_create_pact_publications.rb} +1 -5
  8. data/db/migrations/27_populate_pact_publications.rb +12 -0
  9. data/db/migrations/28_populate_pact_publications.rb +1 -6
  10. data/db/migrations/{33_recreate_all_pacts.rb → 29_create_all_pact_publications.rb} +4 -4
  11. data/db/migrations/{34_recreate_latest_tagged_pacts.rb → 30_create_latest_tagged_pact_publications.rb} +1 -4
  12. data/db/migrations/31_drop_old_tables_and_views.rb +9 -0
  13. data/db/migrations/{35_create_verifications.rb → 32_create_verifications.rb} +0 -0
  14. data/db/migrations/{36_create_latest_verifications.rb → 33_create_latest_verifications.rb} +0 -0
  15. data/db/pact_broker_database.sqlite3 +0 -0
  16. data/lib/pact_broker/pacts/repository.rb +3 -3
  17. data/lib/pact_broker/version.rb +1 -1
  18. data/pact_broker.gemspec +1 -0
  19. data/spec/lib/pact_broker/api/decorators/verifications_decorator_spec.rb +0 -1
  20. data/spec/lib/pact_broker/verifications/service_spec.rb +1 -1
  21. data/spec/lib/pact_broker/versions/repository_spec.rb +1 -1
  22. data/spec/migrations/23_pact_versions_spec.rb +3 -13
  23. data/spec/migrations/24_populate_pact_contents_spec.rb +3 -11
  24. data/spec/migrations/34_latest_tagged_pacts_spec.rb +3 -11
  25. data/spec/migrations/34_pact_revisions_spec.rb +3 -11
  26. data/tasks/database.rb +79 -3
  27. data/tasks/db.rake +4 -0
  28. metadata +25 -14
  29. data/db/migrations/24_populate_pact_contents.rb +0 -9
  30. data/db/migrations/25_populate_pact_contents_pacticipants.rb +0 -7
  31. data/db/migrations/29_recreate_all_pacts.rb +0 -16
  32. data/db/migrations/30_drop_pacts.rb +0 -8
  33. data/db/migrations/31_drop_pact_version_contents.rb +0 -5
  34. data/db/migrations/32_rename_pact_contents.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1868b3d1f43fe2ebee71e30e38088b70faa46c4
4
- data.tar.gz: 6e0947382d1b455892c94b23b41b400ca2c8c7a6
3
+ metadata.gz: a57e6677da73f5beaa4ffaac55c4b2e277a870e6
4
+ data.tar.gz: 9a5f2f22da55e9288cde253de48851fcf87164a1
5
5
  SHA512:
6
- metadata.gz: 0d592dfd992c8de6271f6bfbc30292bd48aa772d2eb914f741882efe853b5677ff8d440ffd41fa30686074dfab7116e1a082dcd87c11870a13adb162cef08161
7
- data.tar.gz: 9dfc13a55c1ea8a00ef5efeed880a81687460030d20ea32c95e639076d70fba98d5c76d6e4b1c90da6eea2fea4ad7c90236a4ba27243f8fbba253b7d9ec6fc81
6
+ metadata.gz: 2e7a0e9ff2e827a051815fb140ef576e8cf8eb194109ac9a5129bb925812be9a917f380860a0c9c609c7caead91c33e409d3212eb6fa3137f5ab4b9a639e9b32
7
+ data.tar.gz: 6e8afbb69538b75be3c972629fffc702e68a910ea1dc6bef59e1fef82c6c8a378dfc3582a01c1cad71cfd82516ebae061a7a0ea958f27cfb14e81dc80a1c23df
data/CHANGELOG.md CHANGED
@@ -2,8 +2,10 @@ Do this to generate your change history
2
2
 
3
3
  $ git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
4
4
 
5
- #### 2.0.0.beta.1 (2017-04-28)
5
+ #### 2.0.0.beta.2 (2017-04-29)
6
+ * 1dfef17 - Cleaned up migrations and ensured migrations run on postgresql. (Beth Skurrie, Fri Apr 28 21:24:20 2017 +1000)
6
7
 
8
+ #### 2.0.0.beta.1 (2017-04-28)
7
9
  * 049bc5c - Added tooltip to verification date to show provider version. (Beth Skurrie, Fri Apr 28 10:05:13 2017 +1000)
8
10
  * 4287c99 - Add tooltip text to last verified date when pact has changed since last verification. (Beth Skurrie, Fri Apr 28 09:02:59 2017 +1000)
9
11
  * 7351ec8 - Add restrictions for all gem versions in gemspec. Fix formatting in haml file. (Beth Skurrie, Thu Apr 27 19:55:04 2017 +1000)
data/config/database.yml CHANGED
@@ -6,6 +6,13 @@ test:
6
6
  <<: *default
7
7
  database: tmp/pact_broker_database_test.sqlite3
8
8
 
9
+ # test:
10
+ # adapter: "postgres"
11
+ # database: "pact_broker"
12
+ # username: 'pact_broker'
13
+ # password: 'pact_broker'
14
+ # encoding: 'utf8'
15
+
9
16
  development:
10
17
  <<: *default
11
18
 
@@ -2,7 +2,7 @@ require_relative 'migration_helper'
2
2
 
3
3
  Sequel.migration do
4
4
  up do
5
- create_table(:pact_contents, charset: 'utf8') do
5
+ create_table(:pact_versions, charset: 'utf8') do
6
6
  primary_key :id
7
7
  foreign_key :consumer_id, :pacticipants
8
8
  foreign_key :provider_id, :pacticipants
@@ -14,6 +14,6 @@ Sequel.migration do
14
14
  end
15
15
 
16
16
  down do
17
- drop_table(:pact_contents)
17
+
18
18
  end
19
19
  end
@@ -0,0 +1,8 @@
1
+ Sequel.migration do
2
+ up do
3
+ run("insert into pact_versions (sha, content, created_at) select sha, content, created_at from pact_version_contents")
4
+ run("update pact_versions set consumer_id = (select consumer_id from all_pacts where pact_version_content_sha = pact_versions.sha limit 1)")
5
+ run("update pact_versions set provider_id = (select provider_id from all_pacts where pact_version_content_sha = pact_versions.sha limit 1)")
6
+ run("delete from pact_versions where consumer_id is null")
7
+ end
8
+ end
@@ -1,6 +1,6 @@
1
1
  Sequel.migration do
2
2
  up do
3
- alter_table(:pact_contents) do
3
+ alter_table(:pact_versions) do
4
4
  set_column_not_null(:consumer_id)
5
5
  set_column_not_null(:provider_id)
6
6
  end
@@ -5,14 +5,10 @@ Sequel.migration do
5
5
  foreign_key :consumer_version_id, :versions, null: false
6
6
  foreign_key :provider_id, :pacticipants, null: false
7
7
  Integer :revision_number, null: false
8
- foreign_key :pact_version_id, :pact_contents, null: false
8
+ foreign_key :pact_version_id, :pact_versions, null: false
9
9
  DateTime :created_at, null: false
10
10
  index [:consumer_version_id, :provider_id, :revision_number], unique: true, name: 'cv_prov_revision_unq'
11
11
  index [:consumer_version_id, :provider_id, :id], name: 'cv_prov_id_ndx'
12
12
  end
13
13
  end
14
-
15
- down do
16
- drop_table(:pact_publications)
17
- end
18
14
  end
@@ -0,0 +1,12 @@
1
+ Sequel.migration do
2
+ up do
3
+ run("insert into pact_publications
4
+ (id, consumer_version_id, provider_id, revision_number, pact_version_id, created_at)
5
+ select ap.id, ap.consumer_version_id, ap.provider_id, 1, pc.id, ap.updated_at
6
+ from all_pacts ap inner join pact_versions pc
7
+ on pc.sha = ap.pact_version_content_sha")
8
+ end
9
+
10
+ down do
11
+ end
12
+ end
@@ -1,13 +1,8 @@
1
1
  Sequel.migration do
2
2
  up do
3
- run("insert into pact_publications
4
- (id, consumer_version_id, provider_id, revision_number, pact_version_id, created_at)
5
- select ap.id, ap.consumer_version_id, ap.provider_id, 1, pc.id, ap.updated_at
6
- from all_pacts ap inner join pact_contents pc
7
- on pc.sha = ap.pact_version_content_sha")
3
+
8
4
  end
9
5
 
10
6
  down do
11
- run("delete from pact_publications")
12
7
  end
13
8
  end
@@ -1,7 +1,7 @@
1
1
  Sequel.migration do
2
2
  up do
3
3
  # The denormalised pact publication details for each publication
4
- create_or_replace_view(:all_pact_publications,
4
+ create_view(:all_pact_publications,
5
5
  Sequel::Model.db[:pact_publications].select(:pact_publications__id,
6
6
  :c__id___consumer_id, :c__name___consumer_name,
7
7
  :cv__id___consumer_version_id, :cv__number___consumer_version_number, :cv__order___consumer_version_order,
@@ -14,14 +14,14 @@ Sequel.migration do
14
14
  )
15
15
 
16
16
  # Latest revision number for each consumer version order
17
- create_or_replace_view(:latest_pact_publication_revision_numbers,
17
+ create_view(:latest_pact_publication_revision_numbers,
18
18
  "select provider_id, consumer_id, consumer_version_order, max(revision_number) as latest_revision_number
19
19
  from all_pact_publications
20
20
  group by provider_id, consumer_id, consumer_version_order"
21
21
  )
22
22
 
23
23
  # Latest pact_publication details for each consumer version
24
- create_or_replace_view(:latest_pact_publications_by_consumer_versions,
24
+ create_view(:latest_pact_publications_by_consumer_versions,
25
25
  "select app.*
26
26
  from all_pact_publications app
27
27
  inner join latest_pact_publication_revision_numbers lr
@@ -39,7 +39,7 @@ Sequel.migration do
39
39
  )
40
40
 
41
41
  # Latest pact publications by consumer/provider
42
- create_or_replace_view(:latest_pact_publications,
42
+ create_view(:latest_pact_publications,
43
43
  "select lpcv.*
44
44
  from latest_pact_publications_by_consumer_versions lpcv
45
45
  inner join latest_pact_consumer_version_orders lp
@@ -8,7 +8,7 @@ Sequel.migration do
8
8
  group by provider_id, consumer_id, t.name"
9
9
  )
10
10
 
11
- create_or_replace_view(:latest_tagged_pact_publications,
11
+ create_view(:latest_tagged_pact_publications,
12
12
  "select lp.*, o.tag_name
13
13
  from latest_pact_publications_by_consumer_versions lp
14
14
  inner join latest_tagged_pact_consumer_version_orders o
@@ -16,8 +16,5 @@ Sequel.migration do
16
16
  and lp.provider_id = o.provider_id
17
17
  and lp.consumer_version_order = latest_consumer_version_order"
18
18
  )
19
-
20
- drop_view(:all_pacts)
21
- drop_view(:latest_pacts)
22
19
  end
23
20
  end
@@ -0,0 +1,9 @@
1
+ Sequel.migration do
2
+ up do
3
+ drop_view(:latest_tagged_pacts)
4
+ drop_view(:latest_pacts)
5
+ drop_view(:all_pacts)
6
+ drop_table(:pacts)
7
+ drop_table(:pact_version_contents)
8
+ end
9
+ end
Binary file
@@ -59,9 +59,9 @@ module PactBroker
59
59
 
60
60
  def find_latest_pact_versions_for_provider provider_name, tag = nil
61
61
  if tag
62
- LatestTaggedPactPublications.provider(provider_name).where(tag_name: tag).collect(&:to_domain)
62
+ LatestTaggedPactPublications.provider(provider_name).where(tag_name: tag).order(:consumer_name).collect(&:to_domain)
63
63
  else
64
- LatestPactPublications.provider(provider_name).collect(&:to_domain)
64
+ LatestPactPublications.provider(provider_name).order(:consumer_name).collect(&:to_domain)
65
65
  end
66
66
  end
67
67
 
@@ -73,7 +73,7 @@ module PactBroker
73
73
  end
74
74
 
75
75
  def find_latest_pacts
76
- LatestPactPublications.collect(&:to_domain_without_tags)
76
+ LatestPactPublications.order(:consumer_name, :provider_name).collect(&:to_domain_without_tags)
77
77
  end
78
78
 
79
79
  def find_latest_pact(consumer_name, provider_name, tag = nil)
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '2.0.0.beta.1'
2
+ VERSION = '2.0.0.beta.2'
3
3
  end
data/pact_broker.gemspec CHANGED
@@ -45,4 +45,5 @@ Gem::Specification.new do |gem|
45
45
  gem.add_development_dependency 'rspec', '~>3.0'
46
46
  gem.add_development_dependency 'rspec-its'
47
47
  gem.add_development_dependency 'database_cleaner'
48
+ gem.add_development_dependency 'pg'
48
49
  end
@@ -10,7 +10,6 @@ module PactBroker
10
10
  success: true, number: 1,
11
11
  provider_version: '4.5.6',
12
12
  build_url: 'http://some-build',
13
- latest_pact_publication: pact,
14
13
  provider_name: 'provider',
15
14
  consumer_name: 'consumer',
16
15
  pact_version: pact_version,
@@ -41,7 +41,7 @@ module PactBroker
41
41
  it "sets the pact content for the verification" do
42
42
  verification = create_verification
43
43
  expect(verification.pact_version_id).to_not be_nil
44
- expect(verification.pact_version.id).to eq pact.id
44
+ expect(verification.pact_version).to_not be_nil
45
45
  end
46
46
  end
47
47
 
@@ -41,7 +41,7 @@ module PactBroker
41
41
  end
42
42
 
43
43
  it "returns the version" do
44
- expect(subject.id).to eq 1
44
+ expect(subject.id).to_not be_nil
45
45
  expect(subject.number).to eq version_number
46
46
  expect(subject.pacticipant.name).to eq pacticipant_name
47
47
  expect(subject.tags.first.name).to eq "prod"
@@ -11,17 +11,10 @@ describe 'migrate to pact versions (migrate 22-31)', no_db_clean: :true do
11
11
  database[table_name].delete rescue puts "Error cleaning #{table_name} #{$!}"
12
12
  end
13
13
 
14
- def new_connection
15
- Sequel::DATABASES.clear
16
- DB.connection_for_env 'test'
17
- end
18
-
19
- let(:database) { new_connection }
14
+ let(:database) { DB.connection_for_env 'test' }
20
15
 
21
16
  before do
22
- PactBroker::Database.delete_database_file
23
- PactBroker::Database.ensure_database_dir_exists
24
- database = new_connection
17
+ PactBroker::Database.drop_objects
25
18
  PactBroker::Database.migrate(22)
26
19
  end
27
20
 
@@ -47,7 +40,6 @@ describe 'migrate to pact versions (migrate 22-31)', no_db_clean: :true do
47
40
 
48
41
  it "uses the old updated date for the new creation date" do
49
42
  do_migration
50
- # expect(new_connection[:latest_pact_publications_by_consumer_versions].order(:id).first[:created_at]).to eq pact_updated_at
51
43
  expect(database[:latest_pact_publications_by_consumer_versions].order(:id).first[:created_at]).to eq pact_updated_at
52
44
  end
53
45
 
@@ -87,9 +79,7 @@ describe 'migrate to pact versions (migrate 22-31)', no_db_clean: :true do
87
79
  end
88
80
 
89
81
  after do
90
- PactBroker::Database.delete_database_file
91
- PactBroker::Database.ensure_database_dir_exists
92
- database = new_connection
93
82
  PactBroker::Database.migrate
83
+ PactBroker::Database.truncate
94
84
  end
95
85
  end
@@ -7,16 +7,10 @@ describe 'migrate to pact versions (migrate 22-24)', no_db_clean: :true do
7
7
  database[table_name].order(id_column_name).last
8
8
  end
9
9
 
10
- def new_connection
11
- DB.connection_for_env 'test'
12
- end
13
-
14
- let(:database) { new_connection }
10
+ let(:database) { DB.connection_for_env 'test' }
15
11
 
16
12
  before do
17
- PactBroker::Database.delete_database_file
18
- PactBroker::Database.ensure_database_dir_exists
19
- database = new_connection
13
+ PactBroker::Database.drop_objects
20
14
  PactBroker::Database.migrate(22)
21
15
  end
22
16
 
@@ -40,9 +34,7 @@ describe 'migrate to pact versions (migrate 22-24)', no_db_clean: :true do
40
34
  end
41
35
 
42
36
  after do
43
- PactBroker::Database.delete_database_file
44
- PactBroker::Database.ensure_database_dir_exists
45
- database = new_connection
46
37
  PactBroker::Database.migrate
38
+ PactBroker::Database.truncate
47
39
  end
48
40
  end
@@ -7,16 +7,10 @@ describe 'using pact publications (migrate 31-32)', no_db_clean: :true do
7
7
  database[table_name].order(id_column_name).last
8
8
  end
9
9
 
10
- def new_connection
11
- DB.connection_for_env 'test'
12
- end
13
-
14
- let(:database) { new_connection }
10
+ let(:database) { DB.connection_for_env 'test' }
15
11
 
16
12
  before do
17
- PactBroker::Database.delete_database_file
18
- PactBroker::Database.ensure_database_dir_exists
19
- database = new_connection
13
+ PactBroker::Database.drop_objects
20
14
  PactBroker::Database.migrate(34)
21
15
  end
22
16
 
@@ -100,9 +94,7 @@ describe 'using pact publications (migrate 31-32)', no_db_clean: :true do
100
94
  end
101
95
 
102
96
  after do
103
- PactBroker::Database.delete_database_file
104
- PactBroker::Database.ensure_database_dir_exists
105
- database = new_connection
106
97
  PactBroker::Database.migrate
98
+ PactBroker::Database.truncate
107
99
  end
108
100
  end
@@ -7,16 +7,10 @@ describe 'using pact publications (migrate 31-32)', no_db_clean: :true do
7
7
  database[table_name].order(id_column_name).last
8
8
  end
9
9
 
10
- def new_connection
11
- DB.connection_for_env 'test'
12
- end
13
-
14
- let(:database) { new_connection }
10
+ let(:database) { DB.connection_for_env 'test' }
15
11
 
16
12
  before do
17
- PactBroker::Database.delete_database_file
18
- PactBroker::Database.ensure_database_dir_exists
19
- database = new_connection
13
+ PactBroker::Database.drop_objects
20
14
  PactBroker::Database.migrate(33)
21
15
  end
22
16
 
@@ -98,9 +92,7 @@ describe 'using pact publications (migrate 31-32)', no_db_clean: :true do
98
92
  end
99
93
 
100
94
  after do
101
- PactBroker::Database.delete_database_file
102
- PactBroker::Database.ensure_database_dir_exists
103
- database = new_connection
104
95
  PactBroker::Database.migrate
96
+ PactBroker::Database.truncate
105
97
  end
106
98
  end
data/tasks/database.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'pact_broker/project_root'
2
2
  require 'sequel'
3
+ require 'yaml'
3
4
  require 'db'
4
5
 
5
6
  Sequel.extension :migration
@@ -7,6 +8,8 @@ Sequel.extension :migration
7
8
  module PactBroker
8
9
  module Database
9
10
 
11
+ TABLES = [:pacts, :pact_version_contents, :tags, :verifications, :pact_publications, :pact_versions, :webhook_headers, :webhooks, :versions, :pacticipants].freeze
12
+
10
13
  extend self
11
14
 
12
15
  def migrate target = nil
@@ -32,14 +35,77 @@ module PactBroker
32
35
  FileUtils.mkdir_p File.dirname(database_file_path)
33
36
  end
34
37
 
38
+ def drop_objects
39
+ drop_views
40
+ drop_tables
41
+ end
42
+
43
+ def drop_tables
44
+ (TABLES + [:schema_info]).each do | table_name |
45
+ if database.table_exists?(table_name)
46
+ database.drop_table(table_name, cascade: psql?)
47
+ end
48
+ end
49
+ end
50
+
51
+ def drop_views
52
+ database.views.each do | view_name |
53
+ begin
54
+ # checking for existance using table_exists? doesn't work in sqlite
55
+ database.drop_view(view_name, cascade: psql?)
56
+ rescue Sequel::DatabaseError => e
57
+ # Cascade will have deleted some views already with pg
58
+ raise e unless e.cause.class.name == 'PG::UndefinedTable'
59
+ end
60
+ end
61
+ end
62
+
63
+ def create
64
+ puts adapter
65
+ if psql?
66
+ system('psql postgres -c "create database pact_broker"')
67
+ system('psql postgres -c "CREATE USER pact_broker WITH PASSWORD \'pact_broker\'"')
68
+ system('psql postgres -c "GRANT ALL PRIVILEGES ON DATABASE pact_broker to pact_broker"')
69
+ elsif sqlite?
70
+ ensure_database_dir_exists
71
+ else
72
+ raise "Unknown database adapter #{adapter}"
73
+ end
74
+ end
75
+
76
+ def recreate
77
+ drop_tables
78
+ create
79
+ end
80
+
81
+ def truncate
82
+ TABLES.each do | table_name |
83
+ if database.table_exists?(table_name)
84
+ database[table_name].delete
85
+ end
86
+ end
87
+ end
88
+
89
+ def database= database
90
+ @@database = database
91
+ end
92
+
93
+ def database
94
+ @@database ||= ::DB.connection_for_env env
95
+ end
96
+
35
97
  private
36
98
 
37
99
  def ensure_not_production
38
100
  raise "Cannot delete production database using this task" if env == 'production'
39
101
  end
40
102
 
41
- def database
42
- ::DB.connection_for_env env
103
+ def psql?
104
+ adapter == 'postgres'
105
+ end
106
+
107
+ def sqlite?
108
+ adapter == 'sqlite'
43
109
  end
44
110
 
45
111
  def migrations_dir
@@ -47,7 +113,17 @@ module PactBroker
47
113
  end
48
114
 
49
115
  def database_file_path
50
- ::DB.configuration_for_env(env)['database']
116
+ configuration_for_env(env)['database']
117
+ end
118
+
119
+ def adapter
120
+ configuration_for_env(env)['adapter']
121
+ end
122
+
123
+ def configuration_for_env env
124
+ database_yml = PactBroker.project_root.join('config','database.yml')
125
+ config = YAML.load(ERB.new(File.read(database_yml)).result)
126
+ config.fetch(env)
51
127
  end
52
128
 
53
129
  def env
data/tasks/db.rake CHANGED
@@ -52,6 +52,10 @@ namespace :db do
52
52
  PactBroker::Database.ensure_database_dir_exists
53
53
  end
54
54
 
55
+ task :create => 'db:env' do
56
+ PactBroker::Database.create
57
+ end
58
+
55
59
  # Private
56
60
  task :set_test_env do
57
61
  ENV['RACK_ENV'] = 'test'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta.1
4
+ version: 2.0.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -346,6 +346,20 @@ dependencies:
346
346
  - - ">="
347
347
  - !ruby/object:Gem::Version
348
348
  version: '0'
349
+ - !ruby/object:Gem::Dependency
350
+ name: pg
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - ">="
354
+ - !ruby/object:Gem::Version
355
+ version: '0'
356
+ type: :development
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - ">="
361
+ - !ruby/object:Gem::Version
362
+ version: '0'
349
363
  description: A server that stores and returns pact files generated by the pact gem.
350
364
  It enables head/prod cross testing of the consumer and provider projects.
351
365
  email:
@@ -393,20 +407,17 @@ files:
393
407
  - db/migrations/20_add_pact_version_content_sha_to_all_pacts_view.rb
394
408
  - db/migrations/21_recreate_latest_pacts_view.rb
395
409
  - db/migrations/22_create_latest_tagged_pacts_view.rb
396
- - db/migrations/23_create_pact_contents_table.rb
397
- - db/migrations/24_populate_pact_contents.rb
398
- - db/migrations/25_populate_pact_contents_pacticipants.rb
399
- - db/migrations/26_make_pc_pacticipants_mandatory.rb
400
- - db/migrations/27_create_pact_publications.rb
410
+ - db/migrations/23_create_pact_versions_table.rb
411
+ - db/migrations/24_populate_pact_versions.rb
412
+ - db/migrations/25_make_pv_pacticipants_mandatory.rb
413
+ - db/migrations/26_create_pact_publications.rb
414
+ - db/migrations/27_populate_pact_publications.rb
401
415
  - db/migrations/28_populate_pact_publications.rb
402
- - db/migrations/29_recreate_all_pacts.rb
403
- - db/migrations/30_drop_pacts.rb
404
- - db/migrations/31_drop_pact_version_contents.rb
405
- - db/migrations/32_rename_pact_contents.rb
406
- - db/migrations/33_recreate_all_pacts.rb
407
- - db/migrations/34_recreate_latest_tagged_pacts.rb
408
- - db/migrations/35_create_verifications.rb
409
- - db/migrations/36_create_latest_verifications.rb
416
+ - db/migrations/29_create_all_pact_publications.rb
417
+ - db/migrations/30_create_latest_tagged_pact_publications.rb
418
+ - db/migrations/31_drop_old_tables_and_views.rb
419
+ - db/migrations/32_create_verifications.rb
420
+ - db/migrations/33_create_latest_verifications.rb
410
421
  - db/migrations/migration_helper.rb
411
422
  - db/pact_broker_database.sqlite3
412
423
  - example/Gemfile
@@ -1,9 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run("insert into pact_contents (sha, content, created_at) select sha, content, created_at from pact_version_contents")
4
- end
5
-
6
- down do
7
- run("delete from pact_contents")
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- run("update pact_contents set consumer_id = (select consumer_id from all_pacts where pact_version_content_sha = pact_contents.sha limit 1)")
4
- run("update pact_contents set provider_id = (select provider_id from all_pacts where pact_version_content_sha = pact_contents.sha limit 1)")
5
- run("delete from pact_contents where consumer_id is null")
6
- end
7
- end
@@ -1,16 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- create_or_replace_view(:all_pacts,
4
- Sequel::Model.db[:pact_publications].select(:pact_publications__id,
5
- :c__id___consumer_id, :c__name___consumer_name,
6
- :cv__id___consumer_version_id, :cv__number___consumer_version_number, :cv__order___consumer_version_order,
7
- :p__id___provider_id, :p__name___provider_name,
8
- :pact_publications__revision_number, :pc__sha___pact_version_sha, :pact_publications__created_at).
9
- join(:versions, {:id => :consumer_version_id}, {:table_alias => :cv, implicit_qualifier: :pact_publications}).
10
- join(:pacticipants, {:id => :pacticipant_id}, {:table_alias => :c, implicit_qualifier: :cv}).
11
- join(:pacticipants, {:id => :provider_id}, {:table_alias => :p, implicit_qualifier: :pact_publications}).
12
- join(:pact_contents, {:id => :pact_version_id}, {:table_alias => :pc, implicit_qualifier: :pact_publications})
13
- )
14
- end
15
- end
16
-
@@ -1,8 +0,0 @@
1
- require 'digest/sha1'
2
- require_relative 'migration_helper'
3
-
4
- Sequel.migration do
5
- up do
6
- drop_table(:pacts)
7
- end
8
- end
@@ -1,5 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- drop_table(:pact_version_contents)
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- Sequel.migration do
2
- up do
3
- rename_table(:pact_contents, :pact_versions)
4
- end
5
- end