percona-online_migrations 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 338713c87dfd0e6ed377d2bb4385fb105b527ade5ce6300ee7432fddc4a023ce
4
+ data.tar.gz: c70dd82727b409ea08aa49e04ddddfc0f03e9ce5d706e31f6c9c0e08aa21a316
5
+ SHA512:
6
+ metadata.gz: 3885e1190f57f1266babf64380b83f8e16cefdf1dd32e8c6a7119f4b4e2101b7bc3e0c71df41a31b6b87c84855991a6c082fd2a821544d3f0751fed9598ea753
7
+ data.tar.gz: 0eb1281570be87cfc45f77d8be552716c31348c2f801e1892047941448035565128435c608b4d9c0de75be2bd96fe64e87a6bfa013ce139b980c12bcbd5c96c8
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ Gemfile.lock
13
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1 @@
1
+ 2.5.1
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,13 @@
1
+ test:
2
+ @ bundle exec rspec
3
+
4
+ build: clear
5
+ @ bundle
6
+ @ gem build percona-online_migrations.gemspec
7
+
8
+ release: test build
9
+ @ gem push *.gem
10
+
11
+ clear:
12
+ @ rm -rf pkg
13
+ @ rm -rf *.gem
File without changes
@@ -0,0 +1,12 @@
1
+ require 'percona/online_migrations/version'
2
+
3
+ module Percona
4
+ module OnlineMigrations
5
+ module MigratedTables
6
+ MAX_MIGRATED_TABLE_AGE = 24 * 3600
7
+ end
8
+ end
9
+ end
10
+
11
+ require 'percona/online_migrations/migrated_tables/drop'
12
+ require 'percona/online_migrations/migrated_tables/filter'
@@ -0,0 +1,12 @@
1
+ class Percona::OnlineMigrations::MigratedTables::Drop
2
+ def self.for(connection)
3
+ tables = connection.tables
4
+ migrated_tables = Percona::OnlineMigrations::MigratedTables::Filter.for(tables)
5
+
6
+ migrated_tables.each do |migrated_table|
7
+ connection.drop_table(migrated_table)
8
+ end
9
+
10
+ true
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ class Percona::OnlineMigrations::MigratedTables::Filter
2
+ class << self
3
+ def for(table_names)
4
+ table_names.select do |table_name|
5
+ old_table?(table_name)
6
+ end
7
+ end
8
+
9
+ private
10
+
11
+ def old_table?(table_name)
12
+ matched = table_name.match(/\A_(?<table_name>\w*)_old_(?<timestamp>\d{10})\z/)
13
+ return unless matched
14
+ migrated_table_age = Time.now.to_i - matched['timestamp'].to_i
15
+ migrated_table_age >= Percona::OnlineMigrations::MigratedTables::MAX_MIGRATED_TABLE_AGE
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Percona
2
+ module OnlineMigrations
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'percona/online_migrations/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'percona-online_migrations'
7
+ spec.version = Percona::OnlineMigrations::VERSION
8
+ spec.authors = ['Justas Kazakauskas']
9
+ spec.email = ['justas.kazakauskas@gmail.com']
10
+
11
+ spec.summary = 'Helpers for using pt-online-schema-change with Rails'
12
+ spec.description = 'Helpers for using pt-online-schema-change with Rails.'
13
+ spec.homepage = 'https://github.com/vinted/percona-online_migrations'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.require_paths = ['lib']
17
+
18
+ spec.add_development_dependency 'activerecord', '~> 5.2'
19
+ spec.add_development_dependency 'bundler', '~> 1.16'
20
+ spec.add_development_dependency 'mysql2', '~> 0.5.2'
21
+ spec.add_development_dependency 'pry', '~> 0.11.3'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~> 3.8'
24
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: percona-online_migrations
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Justas Kazakauskas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-08-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.2'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mysql2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.11.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.11.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.8'
97
+ description: Helpers for using pt-online-schema-change with Rails.
98
+ email:
99
+ - justas.kazakauskas@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".ruby-version"
107
+ - Gemfile
108
+ - Makefile
109
+ - README.md
110
+ - lib/percona/online_migrations.rb
111
+ - lib/percona/online_migrations/migrated_tables/drop.rb
112
+ - lib/percona/online_migrations/migrated_tables/filter.rb
113
+ - lib/percona/online_migrations/version.rb
114
+ - percona-online_migrations.gemspec
115
+ homepage: https://github.com/vinted/percona-online_migrations
116
+ licenses: []
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.7.6
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Helpers for using pt-online-schema-change with Rails
138
+ test_files: []