xmigra 1.6.5 → 1.7.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/lib/xmigra/branch_upgrade.rb +1 -0
- data/lib/xmigra/console.rb +1 -0
- data/lib/xmigra/db_support/psql.rb +4 -3
- data/lib/xmigra/impdecl_migration_adder.rb +2 -1
- data/lib/xmigra/migration_conflict.rb +5 -3
- data/lib/xmigra/new_index_adder.rb +1 -1
- data/lib/xmigra/schema_updater.rb +2 -1
- data/lib/xmigra/vcs_support/git.rb +22 -4
- data/lib/xmigra/vcs_support/svn.rb +10 -0
- data/lib/xmigra/version.rb +1 -1
- data/lib/xmigra.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2417b3d567a7eb7401e6506e0f85ed6497545bd0
|
4
|
+
data.tar.gz: 8ec49a23120cf0ef8a60b0a47dc672bc755d7231
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21d5e5655534a89e5a25bbc67dd80dd33ceb3622e140f98075fe2df7a42765f27fb5a29b509bc9afc986b82f3ff45de4f7f893d8525bf0b2bd7b3f908a10f91f
|
7
|
+
data.tar.gz: 759c3e5cf893add4b0edefe5509858cb415efc46211c4d14eb5124ec444d8b93e5989ba2ee34ff0ae625fb541470354ddf206e869c3a7a14f617b7caa43791a9
|
data/lib/xmigra/console.rb
CHANGED
@@ -554,7 +554,7 @@ module XMigra
|
|
554
554
|
end
|
555
555
|
|
556
556
|
def migration_application_sql
|
557
|
-
PgSQLSpecifics.in_plpgsql
|
557
|
+
PgSQLSpecifics.in_plpgsql(%Q{
|
558
558
|
IF EXISTS (
|
559
559
|
SELECT * FROM temp$xmigra_migrations
|
560
560
|
WHERE "MigrationID" = '#{id}'
|
@@ -562,14 +562,15 @@ module XMigra
|
|
562
562
|
) THEN
|
563
563
|
RAISE NOTICE #{PgSQLSpecifics.string_literal %Q{Applying "#{File.basename(file_path)}":}};
|
564
564
|
|
565
|
-
EXECUTE
|
565
|
+
EXECUTE
|
566
|
+
%s;
|
566
567
|
|
567
568
|
INSERT INTO xmigra.applied ("MigrationID", "Description")
|
568
569
|
VALUES ('#{id}', #{PgSQLSpecifics.string_literal description});
|
569
570
|
|
570
571
|
RAISE NOTICE ' done';
|
571
572
|
END IF;
|
572
|
-
}
|
573
|
+
}) % [PgSQLSpecifics.string_literal(sql)]
|
573
574
|
end
|
574
575
|
|
575
576
|
def reversion_tracking_sql
|
@@ -71,7 +71,7 @@ module XMigra
|
|
71
71
|
# Update the latest implementing migration for any declarative
|
72
72
|
# file that is modified in the working copy
|
73
73
|
each_decohered_implementing_migration(
|
74
|
-
&method(:
|
74
|
+
&method(:fix_decohered_implementing_migration!)
|
75
75
|
)
|
76
76
|
end
|
77
77
|
|
@@ -80,14 +80,16 @@ module XMigra
|
|
80
80
|
latest_impls = tool.migrations.latest_declarative_implementations
|
81
81
|
latest_impls.each_pair do |decl_file, migration|
|
82
82
|
next unless tool.vcs_file_modified?(decl_file)
|
83
|
+
next if tool.vcs_file_modified?(migration.file_path)
|
83
84
|
yield migration.file_path, tool.vcs_latest_revision(migration.file_path)
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
|
-
def
|
88
|
+
def fix_decohered_implementing_migration!(file_path, last_commit)
|
88
89
|
migration_info = YAML.load_file(file_path)
|
90
|
+
last_commit = "nonexistent" if last_commit.nil? || last_commit.empty?
|
89
91
|
migration_info['pre-unbranch'] = last_commit
|
90
|
-
file_path.open('w') do |f|
|
92
|
+
Pathname(file_path).open('w') do |f|
|
91
93
|
$xmigra_yamler.dump(migration_info, f)
|
92
94
|
end
|
93
95
|
end
|
@@ -46,7 +46,8 @@ RUNNING THIS SCRIPT ON A PRODUCTION DATABASE WILL FAIL.
|
|
46
46
|
@file_based_groups << [@branch_upgrade] if @branch_upgrade.found?
|
47
47
|
rescue Error
|
48
48
|
raise
|
49
|
-
rescue StandardError
|
49
|
+
rescue StandardError => e
|
50
|
+
XMigra.log_error(e)
|
50
51
|
raise Error, "Error initializing #{self.class} components"
|
51
52
|
end
|
52
53
|
|
@@ -90,7 +90,7 @@ module XMigra
|
|
90
90
|
end
|
91
91
|
return ($?.success? ? output : nil) if options[:get_result] == :on_success
|
92
92
|
return $?.success? if check_exit
|
93
|
-
raise(VersionControlError, "Git command failed with exit code #{$?.exitstatus}") unless $?.success?
|
93
|
+
raise(VersionControlError, "Git command failed with exit code #{$?.exitstatus}\n Command: #{cmd_str}") unless $?.success?
|
94
94
|
return output unless no_result
|
95
95
|
end
|
96
96
|
|
@@ -352,6 +352,11 @@ module XMigra
|
|
352
352
|
|
353
353
|
return :older
|
354
354
|
elsif a_status == ' '
|
355
|
+
# Look for re-introduction of a declarative that was previously destroyed or renounced
|
356
|
+
if (b_status == '??' || b_status[0] == 'A') && [:renunciation, :destruction].include?(@object.goal)
|
357
|
+
return :unimplemented
|
358
|
+
end
|
359
|
+
|
355
360
|
return :newer unless b_status == ' '
|
356
361
|
|
357
362
|
return begin
|
@@ -422,6 +427,11 @@ module XMigra
|
|
422
427
|
git(:show, "HEAD:#{file_path}", :quiet=>true)
|
423
428
|
end
|
424
429
|
|
430
|
+
def vcs_file_modified?(file_path)
|
431
|
+
gstat = git_retrieve_status(file_path)
|
432
|
+
gstat[0] != ' '
|
433
|
+
end
|
434
|
+
|
425
435
|
def git_status
|
426
436
|
@git_status ||= git_retrieve_status(file_path)
|
427
437
|
end
|
@@ -456,15 +466,16 @@ module XMigra
|
|
456
466
|
return nil unless stage_numbers.sort == [1, 2, 3]
|
457
467
|
|
458
468
|
chain_head = lambda do |stage_number|
|
469
|
+
head_file_relative = head_file.relative_path_from(self.path)
|
459
470
|
return YAML.parse(
|
460
|
-
git(:show, ":#{stage_number}
|
471
|
+
git(:show, ":#{stage_number}:./#{head_file_relative}")
|
461
472
|
).transform
|
462
473
|
end
|
463
474
|
|
464
475
|
# Ours (2) before theirs (3)...
|
465
476
|
heads = [2, 3].collect(&chain_head)
|
466
|
-
# ... unless merging from upstream
|
467
|
-
if self.git_merging_from_upstream?
|
477
|
+
# ... unless merging from upstream or the master branch
|
478
|
+
if self.git_merging_from_upstream? || self.git_merging_from_master?
|
468
479
|
heads.reverse!
|
469
480
|
end
|
470
481
|
|
@@ -565,6 +576,13 @@ module XMigra
|
|
565
576
|
end
|
566
577
|
end
|
567
578
|
|
579
|
+
def git_merging_from_master?
|
580
|
+
git_fetch_master_branch
|
581
|
+
return !(self.git_commits_in? git_master_local_branch..'MERGE_HEAD')
|
582
|
+
rescue VersionControlError
|
583
|
+
return false
|
584
|
+
end
|
585
|
+
|
568
586
|
def git_commits_in?(range, path=nil)
|
569
587
|
git(
|
570
588
|
:log,
|
@@ -227,6 +227,11 @@ END_OF_MESSAGE
|
|
227
227
|
status.nil? || status.attributes['item'] == 'unversioned'
|
228
228
|
end
|
229
229
|
|
230
|
+
def vcs_file_modified?(file_path)
|
231
|
+
status = subversion_retrieve_status(file_path).elements['entry/wc-status']
|
232
|
+
!status.nil? && status.attributes['item'] == 'modified'
|
233
|
+
end
|
234
|
+
|
230
235
|
class VersionComparator
|
231
236
|
# vcs_object.kind_of?(SubversionSpecifics)
|
232
237
|
def initialize(vcs_object, options={})
|
@@ -257,6 +262,11 @@ END_OF_MESSAGE
|
|
257
262
|
|
258
263
|
return :older
|
259
264
|
elsif a_status.attributes['item'] == 'normal'
|
265
|
+
# Look for re-introduction of a declarative that was previously destroyed or renounced
|
266
|
+
if (['unversioned', 'added'].include? b_status.attributes['item']) && [:renunciation, :destruction].include?(@object.goal)
|
267
|
+
return :unimplemented
|
268
|
+
end
|
269
|
+
|
260
270
|
return :newer unless b_status.attributes['item'] == 'normal'
|
261
271
|
|
262
272
|
return begin
|
data/lib/xmigra/version.rb
CHANGED
data/lib/xmigra.rb
CHANGED
@@ -346,12 +346,31 @@ module XMigra
|
|
346
346
|
if e.class.const_defined? :COMMAND_LINE_HELP
|
347
347
|
STDERR.puts(XMigra.program_message(e.class::COMMAND_LINE_HELP))
|
348
348
|
end
|
349
|
+
log_error(e)
|
349
350
|
exit(2) if e.is_a?(OptionParser::ParseError)
|
350
351
|
exit(2) if e.is_a?(XMigra::Program::ArgumentError)
|
351
352
|
exit(1)
|
352
353
|
end
|
353
354
|
)
|
354
355
|
end
|
356
|
+
|
357
|
+
def self.log_error(e)
|
358
|
+
if log_file = ENV['XMIGRA_LOG_FILE']
|
359
|
+
Pathname(log_file).open('a') do |log|
|
360
|
+
log.puts "#{Time.now}: #{e} (#{e.class})"
|
361
|
+
e.backtrace.each do |frame|
|
362
|
+
log.puts " " + frame
|
363
|
+
end
|
364
|
+
|
365
|
+
while e.respond_to?(:cause) && e = e.cause
|
366
|
+
log.puts " Caused by: #{e} (#{e.class})"
|
367
|
+
e.backtrace.each do |frame|
|
368
|
+
log.puts " " + frame
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
355
374
|
end
|
356
375
|
|
357
376
|
require 'xmigra/vcs_support/svn'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmigra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Next IT Corporation
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|