xmigra 1.0.1 → 1.1.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/access_artifact.rb +44 -0
- data/lib/xmigra/access_artifact_collection.rb +50 -0
- data/lib/xmigra/branch_upgrade.rb +62 -0
- data/lib/xmigra/db_support/mssql.rb +1070 -0
- data/lib/xmigra/function.rb +17 -0
- data/lib/xmigra/index.rb +21 -0
- data/lib/xmigra/index_collection.rb +38 -0
- data/lib/xmigra/migration.rb +27 -0
- data/lib/xmigra/migration_chain.rb +63 -0
- data/lib/xmigra/migration_conflict.rb +68 -0
- data/lib/xmigra/new_file.rb +4 -0
- data/lib/xmigra/new_migration_adder.rb +74 -0
- data/lib/xmigra/permission_script_writer.rb +67 -0
- data/lib/xmigra/program.rb +927 -0
- data/lib/xmigra/schema_manipulator.rb +39 -0
- data/lib/xmigra/schema_updater.rb +183 -0
- data/lib/xmigra/stored_procedure.rb +20 -0
- data/lib/xmigra/vcs_support/git.rb +275 -0
- data/lib/xmigra/vcs_support/svn.rb +213 -0
- data/lib/xmigra/version.rb +1 -1
- data/lib/xmigra/view.rb +17 -0
- data/lib/xmigra.rb +47 -3222
- data/test/runner.rb +53 -4
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 841d32e7e4f11988348f7284060272f295f18e4d
|
4
|
+
data.tar.gz: 22dc8eeb6703aa74dc1587f13a7830e61216cec5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1ce7617249b3ec15d7bbad0ad673b15a7620df1f4d7966ce06e67fd15674e16e60b74539c56c89be88b2f559e9cb0c22d0fd812b0d573b91e3fdf2c71e1650d
|
7
|
+
data.tar.gz: e90c716f60ad4bd81c56e7af85c17f594aa6028a895ca91ad8c6dd65b53c044f342bfe12852f6ef555d8eb48e4c2c04f32b64853cac1f46482fd25c30bd82223
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
module XMigra
|
3
|
+
class AccessArtifact
|
4
|
+
def definition_sql
|
5
|
+
[
|
6
|
+
check_existence_sql(false, "%s existed before definition"),
|
7
|
+
creation_notice,
|
8
|
+
creation_sql + ";",
|
9
|
+
check_existence_sql(true, "%s was not created by definition"),
|
10
|
+
insert_access_creation_record_sql,
|
11
|
+
].compact.join(ddl_block_separator)
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :file_path, :filename_metavariable
|
15
|
+
|
16
|
+
def ddl_block_separator
|
17
|
+
"\n"
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_existence_sql(for_existence, error_message)
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def creation_notice
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def creation_sql
|
29
|
+
if metavar = filename_metavariable
|
30
|
+
@definition.gsub(metavar) {|m| self.name}
|
31
|
+
else
|
32
|
+
@definition
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def insert_access_creation_record_sql
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def printable_type
|
41
|
+
self.class.name.split('::').last.scan(/[A-Z]+[a-z]*/).collect {|p| p.downcase}.join(' ')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
require "tsort"
|
3
|
+
|
4
|
+
module XMigra
|
5
|
+
class AccessArtifactCollection
|
6
|
+
def initialize(path, options={})
|
7
|
+
@items = Hash.new
|
8
|
+
db_specifics = options[:db_specifics]
|
9
|
+
filename_metavariable = options[:filename_metavariable]
|
10
|
+
filename_metavariable = filename_metavariable.dup.freeze if filename_metavariable
|
11
|
+
|
12
|
+
XMigra.each_access_artifact(path) do |artifact|
|
13
|
+
@items[artifact.name] = artifact
|
14
|
+
artifact.extend(db_specifics) if db_specifics
|
15
|
+
artifact.filename_metavariable = filename_metavariable
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def [](name)
|
20
|
+
@items[name]
|
21
|
+
end
|
22
|
+
|
23
|
+
def names
|
24
|
+
@items.keys
|
25
|
+
end
|
26
|
+
|
27
|
+
def at_path(fpath)
|
28
|
+
fpath = File.expand_path(fpath)
|
29
|
+
return find {|i| i.file_path == fpath}
|
30
|
+
end
|
31
|
+
|
32
|
+
def each(&block); @items.each_value(&block); end
|
33
|
+
alias tsort_each_node each
|
34
|
+
|
35
|
+
def tsort_each_child(node)
|
36
|
+
node.depends_on.each do |child|
|
37
|
+
yield @items[child]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
include Enumerable
|
42
|
+
include TSort
|
43
|
+
|
44
|
+
def each_definition_sql
|
45
|
+
tsort_each do |artifact|
|
46
|
+
yield artifact.definition_sql
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
require 'xmigra/migration'
|
3
|
+
|
4
|
+
module XMigra
|
5
|
+
class BranchUpgrade
|
6
|
+
TARGET_BRANCH = "resulting branch"
|
7
|
+
MIGRATION_COMPLETED = "completes migration to"
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
@file_path = path
|
11
|
+
@warnings = []
|
12
|
+
|
13
|
+
verinc_info = {}
|
14
|
+
if path.exist?
|
15
|
+
@found = true
|
16
|
+
begin
|
17
|
+
verinc_info = YAML.load_file(path)
|
18
|
+
rescue Error => e
|
19
|
+
warning "Failed to load branch upgrade migration (#{e.class}).\n #{e}"
|
20
|
+
verinc_info = {}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
@base_migration = verinc_info[Migration::FOLLOWS]
|
25
|
+
@target_branch = (XMigra.secure_digest(verinc_info[TARGET_BRANCH]) if verinc_info.has_key? TARGET_BRANCH)
|
26
|
+
@migration_completed = verinc_info[MIGRATION_COMPLETED]
|
27
|
+
@sql = verinc_info['sql']
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_reader :file_path, :base_migration, :target_branch, :migration_completed, :sql
|
31
|
+
|
32
|
+
def found?
|
33
|
+
@found
|
34
|
+
end
|
35
|
+
|
36
|
+
def applicable?(mig_chain)
|
37
|
+
return false if mig_chain.length < 1
|
38
|
+
return false unless (@base_migration && @target_branch)
|
39
|
+
|
40
|
+
return File.basename(mig_chain[-1].file_path) == XMigra.yaml_path(@base_migration)
|
41
|
+
end
|
42
|
+
|
43
|
+
def has_warnings?
|
44
|
+
not @warnings.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
def warnings
|
48
|
+
@warnings.dup
|
49
|
+
end
|
50
|
+
|
51
|
+
def migration_completed_id
|
52
|
+
Migration.id_from_filename(XMigra.yaml_path(migration_completed))
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def warning(s)
|
58
|
+
s.freeze
|
59
|
+
@warnings << s
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|