mysql_framework 2.1.5 → 2.1.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e1cae192a6864318bec19e54ce0bc4db409f393493884dd7455be0809ac8bc0
4
- data.tar.gz: d8ab5dfaf00a88efc3addb04e66c84bc8a614a9f827651a4b37581a3a71936f3
3
+ metadata.gz: 243312b0bb9c568e535dd002ebcf30b8896d433067a10bfdf781ba2c2b47d2c7
4
+ data.tar.gz: 62bbf2d7b89889902ecd781050b0ebbb1a4f7c79a6095ba652d92ce7c644b833
5
5
  SHA512:
6
- metadata.gz: 97152eedd702ad53bc27655e47eab758cd53f1e01fc756f493ebfba8e8bb618a99307c7c717d40ea4aaf331c8c5d16d5ec45dc3dc4fc36391beec50dad8a1cbe
7
- data.tar.gz: 555e02b1f2f0a6eabb07a07a4651c39f7c1d400b843f2e21a3e6ee8e3268d4319e682c7702d0e5a2fe12ffd0e8b344ff8ab5b39adfbd7d1c60c150d385ba4fc6
6
+ metadata.gz: 5fc999ca91c3f06506e0aa41b9ac8c30a23b0322458db992a3849e4842a2045c95605e1994cc0d4a56d01f4e5bd6d910d49a159aebcb157b0150361393d1a174
7
+ data.tar.gz: cd9341f57273a1fb72eb3a2c61c1e4837a2966fb04ad41fb6157f39a33b840ae3356d1b3671a80d08a2d86baae89e4c42d7c9876c13d7214c8574c3a1516f339
@@ -50,6 +50,21 @@ module MysqlFramework
50
50
  result.count >= 1
51
51
  end
52
52
 
53
+ def index_up_to_date?(client, table_name, index_name, columns)
54
+ result = client.query(<<~SQL)
55
+ SHOW INDEX FROM #{table_name} WHERE Key_name="#{index_name}";
56
+ SQL
57
+
58
+ return false if result.size != columns.size
59
+
60
+ index_columns = result.sort_by { |column| column[:Seq_in_index] }
61
+ index_columns.each_with_index do |column, i|
62
+ return false if column[:Column_name] != columns[i]
63
+ end
64
+
65
+ true
66
+ end
67
+
53
68
  protected
54
69
 
55
70
  def generate_partition_sql
@@ -8,7 +8,7 @@ module MysqlFramework
8
8
  end
9
9
 
10
10
  def execute
11
- lock_manager.with_lock(key: self.class) do
11
+ lock_manager.with_lock(key: self.class.name) do
12
12
  initialize_script_history
13
13
 
14
14
  executed_scripts = retrieve_executed_scripts
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MysqlFramework
4
- VERSION = '2.1.5'
4
+ VERSION = '2.1.8'
5
5
  end
@@ -86,4 +86,28 @@ describe MysqlFramework::Scripts::Base do
86
86
  expect(subject.index_exists?(client,'foo','bar')).to eq(false)
87
87
  end
88
88
  end
89
+
90
+ describe '#index_up_to_date?' do
91
+ before do
92
+ expect(client).to receive(:query).and_return(
93
+ [{ Column_name: 'b', Seq_in_index: 2 }, { Column_name: 'a', Seq_in_index: 1 }]
94
+ )
95
+ end
96
+
97
+ it 'returns true when index is up to date' do
98
+ expect(subject.index_up_to_date?(client, 'foo', 'bar', ['a', 'b'])).to eq(true)
99
+ end
100
+
101
+ it 'returns false when index is missing a column' do
102
+ expect(subject.index_up_to_date?(client, 'foo', 'bar', ['a', 'b', 'c'])).to eq(false)
103
+ end
104
+
105
+ it 'returns false when index is having too many columns' do
106
+ expect(subject.index_up_to_date?(client, 'foo', 'bar', ['a'])).to eq(false)
107
+ end
108
+
109
+ it 'returns false when index has columns in wrong order' do
110
+ expect(subject.index_up_to_date?(client, 'foo', 'bar', ['b', 'a'])).to eq(false)
111
+ end
112
+ end
89
113
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-21 00:00:00.000000000 Z
11
+ date: 2023-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake