sql_migrate 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sql_migrate.rb +0 -3
- data/lib/sql_migrate/cli.rb +7 -6
- data/lib/sql_migrate/config.rb +2 -0
- data/lib/sql_migrate/migrator.rb +4 -2
- data/lib/sql_migrate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87a32b76fff03fb755c2f387f3eb052cb2d31fc555cad33f9d0f2686dec8ac84
|
4
|
+
data.tar.gz: 857211ee9f863b0d00b02a3e62e7b388acc8f216dc94bfd32239adf06d9eff48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6cbb287ea0fd0e8107e349a91eb6a49445240506c9c3b7c80e7fcb8f7c3d501c7524cd6b90939758897da044f14c1bc77a165badcaf74857c3ea3b3d4e62f85
|
7
|
+
data.tar.gz: 874f92ce09dfcc3aa330cc18931e2311d7821f53b9480fbea590f859e0aeb95c23a724eb72c49144ace44099ab64c04bc45a310f771c999309efa8c4ba907b65
|
data/lib/sql_migrate.rb
CHANGED
data/lib/sql_migrate/cli.rb
CHANGED
@@ -22,14 +22,15 @@ module SqlMigrate
|
|
22
22
|
OptionParser.new do |opt|
|
23
23
|
opt.version = VERSION
|
24
24
|
opt.banner = "sql_migrate [options] MIGRATIONS_PATH"
|
25
|
-
opt.on("-h HOST") { |v| options[:host]
|
26
|
-
opt.on("-p PORT") { |v| options[:port]
|
25
|
+
opt.on("-h HOST") { |v| options[:host] = v }
|
26
|
+
opt.on("-p PORT") { |v| options[:port] = v }
|
27
27
|
opt.on("-d DATABASE") { |v| options[:database] = v }
|
28
|
-
opt.on("-u USER") { |v| options[:user]
|
28
|
+
opt.on("-u USER") { |v| options[:user] = v }
|
29
29
|
opt.on("-p PASSWORD") { |v| options[:password] = v }
|
30
|
-
opt.on("-v", "--verbose") { |v| options[:verbose]
|
31
|
-
opt.on("-n", "--dry-run") { |v| options[:dryrun]
|
32
|
-
opt.on("
|
30
|
+
opt.on("-v", "--verbose") { |v| options[:verbose] = v }
|
31
|
+
opt.on("-n", "--dry-run") { |v| options[:dryrun] = v }
|
32
|
+
opt.on("--applied") { |v| options[:applied] = v }
|
33
|
+
opt.on("-f CONFIG") { |v| options[:config] = v }
|
33
34
|
opt.parse!(args)
|
34
35
|
end
|
35
36
|
|
data/lib/sql_migrate/config.rb
CHANGED
@@ -10,6 +10,7 @@ module SqlMigrate
|
|
10
10
|
:logger,
|
11
11
|
:dryrun,
|
12
12
|
:verbose,
|
13
|
+
:applied,
|
13
14
|
].freeze
|
14
15
|
|
15
16
|
attr_accessor *VALID_OPTIONS
|
@@ -33,6 +34,7 @@ module SqlMigrate
|
|
33
34
|
self.logger = default_logger
|
34
35
|
self.dryrun = false
|
35
36
|
self.verbose = false
|
37
|
+
self.applied = false
|
36
38
|
end
|
37
39
|
|
38
40
|
private
|
data/lib/sql_migrate/migrator.rb
CHANGED
@@ -17,8 +17,10 @@ module SqlMigrate
|
|
17
17
|
migration_files.each do |migration|
|
18
18
|
version_name = File.basename(migration)
|
19
19
|
next if versions.include?(version_name)
|
20
|
-
|
21
|
-
|
20
|
+
unless config.applied
|
21
|
+
logger.info("apply migration #{version_name}")
|
22
|
+
queries_from_migration_file(migration).each { |sql| execute(sql) }
|
23
|
+
end
|
22
24
|
sql = "insert into #{VERSION_TABLE_NAME} (`version`) values (\"#{version_name}\")"
|
23
25
|
execute(sql)
|
24
26
|
end
|
data/lib/sql_migrate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sql_migrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- i2bskn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|