migu 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 575e9aba3368e61fd768bc9ecb89f8476f76a1f2ef8fb30ecc22d4adc7f4b43a
4
- data.tar.gz: d623cfa8ff2de0225bcaf15f7782bab9bfda9928f088aa8bfdb9aa8a46336d93
3
+ metadata.gz: cb8dac4cd9a3a65e242dbef805078d699c13362470ca39e703b765ed96dc337a
4
+ data.tar.gz: 4f948260286197e4e7782439cd34dc0cb40854d12e782454182f09e89845e972
5
5
  SHA512:
6
- metadata.gz: e5dabb2a7b313d60fec1fd04267db995f43e5ea0a5363e06fc3b7d276af80ad837052d36020d0d0c6a67ee03a8ad1f98ee758617509e978ae3f5d43e9612bfd0
7
- data.tar.gz: 5a56a63448ebbc80448100f1b9f8173c84154650d00edc99516bc0fd2a393214be5c1ca870473569ab90e54cb344831026f1f60685ddcb17dee32c6b9ae396b8
6
+ metadata.gz: c1e6038b630738067bd072ec883bc91f5d2e3c8c323f2b93cdf711611b49cbe962bfcd9803a0e53898a0f0a3f61ba4423c316ebed73f70ad64b4417cabbffc07
7
+ data.tar.gz: 7064838d97ca8a52579099f7fdc1923c8ac91d0941a659c7b8709bff95454c6588f3a3ee9e1e6151de2068491e28e1c4d1fb6161f90ccfe65bd59cd0ad7d0f19
data/Gemfile.lock CHANGED
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- migu (0.1.0)
5
- activesupport (~> 4.2)
4
+ migu (0.1.1)
5
+ activesupport (>= 4.2, < 8.0)
6
6
  dry-cli (~> 1.0)
7
7
  sqlite3 (~> 1.6)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (4.2.11.3)
13
- i18n (~> 0.7)
14
- minitest (~> 5.1)
15
- thread_safe (~> 0.3, >= 0.3.4)
16
- tzinfo (~> 1.1)
12
+ activesupport (7.0.6)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
17
  concurrent-ruby (1.2.2)
18
18
  diff-lcs (1.5.0)
19
19
  dry-cli (1.0.0)
20
- i18n (0.9.5)
20
+ i18n (1.14.1)
21
21
  concurrent-ruby (~> 1.0)
22
22
  minitest (5.18.1)
23
23
  rake (13.0.6)
@@ -36,9 +36,8 @@ GEM
36
36
  rspec-support (3.12.1)
37
37
  sqlite3 (1.6.3-arm64-darwin)
38
38
  sqlite3 (1.6.3-x86_64-linux)
39
- thread_safe (0.3.6)
40
- tzinfo (1.2.11)
41
- thread_safe (~> 0.1)
39
+ tzinfo (2.0.6)
40
+ concurrent-ruby (~> 1.0)
42
41
 
43
42
  PLATFORMS
44
43
  arm64-darwin-22
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Migu
2
2
 
3
- Migu is a migration tool for vector databases that lack a well-established migration mechanism. It is implemented as a Ruby code base.
3
+ Migu is a plain Ruby code base migration tool for vector databases that lack a well-established migration mechanism.
4
4
 
5
5
  ## Installation
6
6
 
@@ -62,6 +62,7 @@ class CreateUsers < Migu::Migration
62
62
  end
63
63
 
64
64
  def down
65
+ client = Weaviate::Client.new
65
66
  client.schema.delete(
66
67
  # ...
67
68
  )
@@ -85,7 +86,6 @@ migu rollback
85
86
 
86
87
  ```bash
87
88
  $ migu ls
88
- bundle exec migu ls
89
89
  CreateUsers migrated
90
90
  CreatePosts not_migrated
91
91
  ```
data/exe/migu CHANGED
@@ -21,11 +21,9 @@ module Migu
21
21
  desc "Initialize Migu SQLite3 database. migu/state.sqlite3 will be created."
22
22
 
23
23
  def call(*)
24
- if Migu::State.new.db.execute("select * from sqlite_master where type = 'table' and name = 'state'").empty?
25
- puts "Already initialized"
26
- return
27
- end
28
24
  Migu::State.new.create_table
25
+ Migu.generate_config
26
+
29
27
  puts "Migu initialized"
30
28
  end
31
29
  end
@@ -31,5 +31,23 @@ EOS
31
31
  return filepath
32
32
  end
33
33
  end
34
+
35
+ def generate_config
36
+ Dir.mkdir("migu") unless Dir.exist?("migu")
37
+ filepath = "migu/config.rb"
38
+ File.open(filepath, "w") do |file|
39
+ file.write(<<-EOS)
40
+ Migu.configuration do |config|
41
+ config.before do
42
+ # before hook
43
+ end
44
+
45
+ config.after do
46
+ # after hook
47
+ end
48
+ end
49
+ EOS
50
+ end
51
+ end
34
52
  end
35
53
  end
data/lib/migu/migrator.rb CHANGED
@@ -11,6 +11,7 @@ module Migu
11
11
  end
12
12
 
13
13
  def migrate
14
+ Migu.configuration.before_hook.call
14
15
  migrations.each do |migration|
15
16
  unless state.find(migration.name)
16
17
  puts "==== Migrate #{migration.name} ===="
@@ -18,9 +19,11 @@ module Migu
18
19
  state.insert(migration.name, migration.time.to_s)
19
20
  end
20
21
  end
22
+ Migu.configuration.after_hook.call
21
23
  end
22
24
 
23
25
  def rollback
26
+ Migu.configuration.before_hook.call
24
27
  if state.migrated.empty?
25
28
  puts "==== No migrations to rollback ===="
26
29
  return
@@ -31,6 +34,7 @@ module Migu
31
34
  puts "==== Rollback #{migration.name} ===="
32
35
  migration.new.down
33
36
  state.delete(migration.name)
37
+ Migu.configuration.after_hook.call
34
38
  end
35
39
  end
36
40
  end
data/lib/migu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Migu
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/migu.rb CHANGED
@@ -13,4 +13,45 @@ end
13
13
  module Migu
14
14
  class Error < StandardError; end
15
15
  # Your code goes here...
16
+
17
+ def self.generate_config
18
+ Dir.mkdir("migu") unless Dir.exist?("migu")
19
+ filepath = "migu/config.rb"
20
+ File.open(filepath, "w") do |file|
21
+ file.write(<<-EOS)
22
+ Migu.configuration do |config|
23
+ config.before do
24
+ # before hook
25
+ end
26
+
27
+ config.after do
28
+ # after hook
29
+ end
16
30
  end
31
+ EOS
32
+ end
33
+ end
34
+
35
+ def self.configuration(&block)
36
+ @configuration ||= Configuration.new
37
+ block.call(@configuration) if block_given?
38
+ @configuration
39
+ end
40
+
41
+ class Configuration
42
+ attr_accessor :before_hook, :after_hook
43
+
44
+ def initialize
45
+ end
46
+
47
+ def before(&block)
48
+ @before_hook = block
49
+ end
50
+
51
+ def after(&block)
52
+ @after_hook = block
53
+ end
54
+ end
55
+ end
56
+
57
+ load "migu/config.rb" if File.exist?("migu/config.rb")
data/migu.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  # Uncomment to register a new dependency of your gem
32
32
  spec.add_dependency "sqlite3", "~> 1.6"
33
33
  spec.add_dependency "dry-cli", "~> 1.0"
34
- spec.add_dependency "activesupport", "~> 4.2"
34
+ spec.add_dependency "activesupport", ">= 4.2", "< 8.0"
35
35
 
36
36
  # For more information and examples about making a new gem, check out our
37
37
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: migu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-30 00:00:00.000000000 Z
11
+ date: 2023-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -42,16 +42,22 @@ dependencies:
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.2'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '8.0'
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
57
  version: '4.2'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '8.0'
55
61
  description: Ruby code base migration tool.
56
62
  email:
57
63
  - me@moeki.dev