seed-snapshot 0.5.2 → 0.6.0
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 +4 -4
- data/.github/workflows/main.yml +21 -20
- data/README.md +2 -4
- data/gemfiles/{ar_6_1.gemfile → ar_7.0.gemfile} +1 -1
- data/gemfiles/ar_7.1.gemfile +9 -0
- data/gemfiles/ar_7.2.gemfile +9 -0
- data/gemfiles/ar_8.0.gemfile +9 -0
- data/lib/seed/configuration.rb +4 -1
- data/lib/seed/mysql.rb +2 -2
- data/lib/seed/snapshot.rb +6 -1
- data/lib/seed_snapshot/version.rb +1 -1
- data/seed-snapshot.gemspec +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90069e1b7ee4498d79d7ae215173663cc360b0dda9ac7df7e4413e0faa177fc0
|
4
|
+
data.tar.gz: 632a91e5023b4c76fb35c8f04d0667d7569572283b589f04c1ce333c296535d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a02a6935e5df0947f2af651630ddb4bf9398e30dc9fba0a8386d1898109f71f67fd06ec7c6ae7bdc2ff11cf41c2c4e8c041efe1650248ddc7e4f00fcc1d8d941
|
7
|
+
data.tar.gz: f6f95d24fcec890787caa28fd255638fba2845508d0865ffcea9e0ca09335adea65abfe9d36b92016a3073b73d0dbb50ce43b3220ad3790020b17decbfc0d4c9
|
data/.github/workflows/main.yml
CHANGED
@@ -16,9 +16,11 @@ jobs:
|
|
16
16
|
build:
|
17
17
|
runs-on: ubuntu-latest
|
18
18
|
|
19
|
+
name: test (ruby:${{ matrix.ruby }}, ar:${{ matrix.ar }})
|
20
|
+
|
19
21
|
services:
|
20
22
|
mysql:
|
21
|
-
image: mysql:
|
23
|
+
image: mysql:8.0
|
22
24
|
env:
|
23
25
|
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
24
26
|
MYSQL_DATABASE: 'activerecord_unittest'
|
@@ -27,27 +29,26 @@ jobs:
|
|
27
29
|
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 10
|
28
30
|
|
29
31
|
strategy:
|
32
|
+
fail-fast: false
|
30
33
|
matrix:
|
31
|
-
ruby
|
32
|
-
|
34
|
+
ruby: ['3.1', '3.2', '3.3']
|
35
|
+
ar: ['7.0', '7.1', '7.2', '8.0']
|
36
|
+
exclude:
|
37
|
+
- ruby: '3.1'
|
38
|
+
ar: '8.0'
|
33
39
|
|
34
40
|
env:
|
35
|
-
BUNDLE_GEMFILE: ${{ matrix.
|
41
|
+
BUNDLE_GEMFILE: gemfiles/ar_${{ matrix.ar }}.gemfile
|
36
42
|
|
37
43
|
steps:
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
gem install bundler
|
50
|
-
bundle install --jobs 3 --retry 3
|
51
|
-
|
52
|
-
- name: Run tests
|
53
|
-
run: bundle exec rake
|
44
|
+
- name: Checkout
|
45
|
+
uses: actions/checkout@v4
|
46
|
+
|
47
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
48
|
+
uses: ruby/setup-ruby@v1
|
49
|
+
with:
|
50
|
+
ruby-version: ${{ matrix.ruby }}
|
51
|
+
bundler-cache: true
|
52
|
+
|
53
|
+
- name: Run tests
|
54
|
+
run: bundle exec rake
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# seed-snapshot
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
This library manage of dump/restore data by database.
|
3
|
+
The library that easily and quickly dumps and restores seed data.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
data/lib/seed/configuration.rb
CHANGED
@@ -41,7 +41,10 @@ module Seed
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def get_all_versions
|
44
|
-
if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new('
|
44
|
+
if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new('7.1')
|
45
|
+
migration_paths = ::ActiveRecord::Migrator.migrations_paths
|
46
|
+
::ActiveRecord::MigrationContext.new(migration_paths).get_all_versions
|
47
|
+
elsif ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new('6.0')
|
45
48
|
migration_paths = ::ActiveRecord::Migrator.migrations_paths
|
46
49
|
::ActiveRecord::MigrationContext.new(migration_paths, ::ActiveRecord::SchemaMigration).get_all_versions
|
47
50
|
elsif ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new('5.2')
|
data/lib/seed/mysql.rb
CHANGED
@@ -10,13 +10,13 @@ module Seed
|
|
10
10
|
''
|
11
11
|
end
|
12
12
|
|
13
|
-
cmd = "MYSQL_PWD=#{password} mysqldump -u #{username} -h #{host} #{database} -t #{allow_tables_option(tables)} #{ignore_tables_option(ignore_tables)} --no-tablespaces #{additional_options} > #{file_path}"
|
13
|
+
cmd = "MYSQL_PWD=#{password} mysqldump -u #{username} -h #{host} -P #{port} #{database} -t #{allow_tables_option(tables)} #{ignore_tables_option(ignore_tables)} --no-tablespaces #{additional_options} > #{file_path}"
|
14
14
|
system cmd
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.restore(file_path, username:, password:, host:, port:, database:)
|
18
18
|
host = 'localhost' unless host
|
19
|
-
cmd = "MYSQL_PWD=#{password} mysql -u #{username} -h #{host} #{database} < #{file_path}"
|
19
|
+
cmd = "MYSQL_PWD=#{password} mysql -u #{username} -h #{host} -P #{port} #{database} < #{file_path}"
|
20
20
|
system cmd
|
21
21
|
end
|
22
22
|
|
data/lib/seed/snapshot.rb
CHANGED
@@ -68,11 +68,16 @@ module Seed
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
IGNORED_TABLES = [
|
72
|
+
'ar_internal_metadata',
|
73
|
+
'schema_migrations'
|
74
|
+
].freeze
|
75
|
+
|
71
76
|
def ignore_tables(classes)
|
72
77
|
db = @configuration.database_options[:database]
|
73
78
|
|
74
79
|
# mysqldump `--ignore-table` options require database name.
|
75
|
-
tables(classes).
|
80
|
+
tables(classes).concat(IGNORED_TABLES).map {|t| "#{db}.#{t}" }
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
data/seed-snapshot.gemspec
CHANGED
@@ -17,5 +17,5 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ['lib']
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
19
|
|
20
|
-
spec.add_runtime_dependency 'activerecord', '>=
|
20
|
+
spec.add_runtime_dependency 'activerecord', '>= 7.0'
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seed-snapshot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yo_waka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '7.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '7.0'
|
27
27
|
description: Easy dump/restore tool for ActiveRecord.
|
28
28
|
email:
|
29
29
|
- y.wakahara@gmail.com
|
@@ -39,7 +39,10 @@ files:
|
|
39
39
|
- Rakefile
|
40
40
|
- bin/console
|
41
41
|
- bin/setup
|
42
|
-
- gemfiles/
|
42
|
+
- gemfiles/ar_7.0.gemfile
|
43
|
+
- gemfiles/ar_7.1.gemfile
|
44
|
+
- gemfiles/ar_7.2.gemfile
|
45
|
+
- gemfiles/ar_8.0.gemfile
|
43
46
|
- lib/seed-snapshot.rb
|
44
47
|
- lib/seed/configuration.rb
|
45
48
|
- lib/seed/manifest.rb
|
@@ -67,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
70
|
- !ruby/object:Gem::Version
|
68
71
|
version: '0'
|
69
72
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
73
|
+
rubygems_version: 3.5.9
|
71
74
|
signing_key:
|
72
75
|
specification_version: 4
|
73
76
|
summary: Easy dump/restore tool for ActiveRecord.
|