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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf0854e7d0c55c6f098e8dc1bad22a3bcc4daae7b5211bfb610899e1b6a34d4f
4
- data.tar.gz: b137afa57c686f02ea0c966854d60067ea1fc3c022d4390819e7a77ecab357aa
3
+ metadata.gz: 87a32b76fff03fb755c2f387f3eb052cb2d31fc555cad33f9d0f2686dec8ac84
4
+ data.tar.gz: 857211ee9f863b0d00b02a3e62e7b388acc8f216dc94bfd32239adf06d9eff48
5
5
  SHA512:
6
- metadata.gz: c0bd293098cdc947c0f12bf494c20e7cf23977cae83cc164ceba50b21fc1b96e235d5dda485fb1456aa95872d15ad5c63919b9edb4a977c33b80ecde7c77fc02
7
- data.tar.gz: 535d32464c6c8df05154084ccf353fb5c91b09f7dbfca3ebd3cfa1143e3750081f449957778d4e0db2e11dd4a55f8794836979d8a329ccec499b74c1e1a137dc
6
+ metadata.gz: f6cbb287ea0fd0e8107e349a91eb6a49445240506c9c3b7c80e7fcb8f7c3d501c7524cd6b90939758897da044f14c1bc77a165badcaf74857c3ea3b3d4e62f85
7
+ data.tar.gz: 874f92ce09dfcc3aa330cc18931e2311d7821f53b9480fbea590f859e0aeb95c23a724eb72c49144ace44099ab64c04bc45a310f771c999309efa8c4ba907b65
@@ -4,6 +4,3 @@ require "mysql2"
4
4
  require "sql_migrate/version"
5
5
  require "sql_migrate/config"
6
6
  require "sql_migrate/migrator"
7
-
8
- module SqlMigrate
9
- end
@@ -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] = v }
26
- opt.on("-p PORT") { |v| options[:port] = v }
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] = v }
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] = v }
31
- opt.on("-n", "--dry-run") { |v| options[:dryrun] = v }
32
- opt.on("-f CONFIG") { |v| options[:config] = v }
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
 
@@ -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
@@ -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
- logger.info("apply migration #{version_name}")
21
- queries_from_migration_file(migration).each { |sql| execute(sql) }
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
@@ -1,3 +1,3 @@
1
1
  module SqlMigrate
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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
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-22 00:00:00.000000000 Z
11
+ date: 2018-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler