orientdb-schema-migrator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +50 -0
- data/Rakefile +58 -0
- data/lib/orientdb-schema-migrator.rb +13 -0
- data/lib/orientdb_schema_migrator/migration.rb +111 -0
- data/lib/orientdb_schema_migrator/migration_generator.rb +59 -0
- data/lib/orientdb_schema_migrator/migrator.rb +125 -0
- data/lib/orientdb_schema_migrator/proxy.rb +26 -0
- data/lib/orientdb_schema_migrator/railtie.rb +10 -0
- data/lib/orientdb_schema_migrator/templates/migration_template.rb +7 -0
- data/lib/orientdb_schema_migrator/version.rb +3 -0
- data/lib/tasks/orientdb_schema_migrator.rake +67 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1248c231b6e9daabc14adad92504c3c554bf5c99
|
4
|
+
data.tar.gz: 567fdd36e4f5420c8be2c50474870eabffac84d0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c3fee532d00b7257a074de17c5da9f5802be37f0b1ba3e03e835db913bb5ed6d52a27229ed4e645ad0e7f81c1a21775792ed996f96f381292a0e13ee97d5c86f
|
7
|
+
data.tar.gz: 1599105f1143cab750e070362a4ff5c59101a05a9371fa851015d4473dcd804cba5600fffb1ae1e67bd99faa777d292d84e02427df6f961228962b00e7dd5495
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 CoPromote
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# OrientdbSchemaMigrator
|
2
|
+
|
3
|
+
Migrate Orientdb schema.
|
4
|
+
|
5
|
+
Uses a `schema_versions` class to keep track of migrations.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'orientdb-schema-migrator'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install orientdb-schema-migrator
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Create Migration
|
24
|
+
|
25
|
+
`rake odb:generate_migration migration_name=CreateFoos`
|
26
|
+
|
27
|
+
### Migrate
|
28
|
+
|
29
|
+
`rake odb:migrate`
|
30
|
+
|
31
|
+
### Rollback
|
32
|
+
|
33
|
+
Rollback (one migration at a time).
|
34
|
+
|
35
|
+
`rake odb:rollback`
|
36
|
+
|
37
|
+
## Testing
|
38
|
+
|
39
|
+
1. Install OrientDb and run it locally.
|
40
|
+
2. Create a database named `schema_test` with an admin user named `test`, password `test` (or provide your own credentials via environment variables).
|
41
|
+
You can test that this is correctly setup with `rake db:test_connection`.
|
42
|
+
3. `rake spec`
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it ( https://github.com/Headlinerfm/orientdb-schema-migrator/fork )
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
task :console do
|
4
|
+
require 'pry'
|
5
|
+
require 'orientdb-schema-migrator'
|
6
|
+
ARGV.clear
|
7
|
+
Pry.start
|
8
|
+
end
|
9
|
+
|
10
|
+
db_namespace = namespace :db do
|
11
|
+
require 'orientdb-schema-migrator'
|
12
|
+
db = ENV['odb_schema_test_db'] || 'schema_test'
|
13
|
+
db_user = ENV['odb_schema_test_user'] || 'test'
|
14
|
+
db_pass = ENV['odb_schema_test_pass'] || 'test'
|
15
|
+
config = {
|
16
|
+
database: db,
|
17
|
+
user: db_user,
|
18
|
+
password: db_pass
|
19
|
+
}
|
20
|
+
|
21
|
+
task :connect do
|
22
|
+
OrientdbSchemaMigrator::ODBClient.connect(:database => db, :user => db_user, :password => db_pass)
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Verify your orientdb test database setup"
|
26
|
+
task :verify_test_db do
|
27
|
+
if OrientdbSchemaMigrator::ODBClient.database_exists?(config)
|
28
|
+
puts "Test database exists"
|
29
|
+
else
|
30
|
+
raise "Failure: database does not exist"
|
31
|
+
end
|
32
|
+
|
33
|
+
db_namespace['connect'].invoke
|
34
|
+
if OrientdbSchemaMigrator::Migration.class_exists?('schema_versions')
|
35
|
+
puts "`schema_versions` exists"
|
36
|
+
else
|
37
|
+
raise "Failure: `schema_versions` table does not exist"
|
38
|
+
end
|
39
|
+
|
40
|
+
puts "Success"
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Add the `schema_versions` class to your database"
|
44
|
+
task :add_schema_class => [:connect] do
|
45
|
+
OrientdbSchemaMigrator::Migration.create_class('schema_versions')
|
46
|
+
OrientdbSchemaMigrator::Migration.add_property('schema_versions', 'schema_version', 'string')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require 'rspec/core/rake_task'
|
52
|
+
|
53
|
+
RSpec::Core::RakeTask.new(:spec)
|
54
|
+
|
55
|
+
task :default => :spec
|
56
|
+
rescue LoadError
|
57
|
+
# no rspec available
|
58
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "orientdb4r"
|
2
|
+
|
3
|
+
require "orientdb_schema_migrator/version"
|
4
|
+
require "orientdb_schema_migrator/migration"
|
5
|
+
require "orientdb_schema_migrator/migration_generator"
|
6
|
+
require "orientdb_schema_migrator/migrator"
|
7
|
+
require "orientdb_schema_migrator/proxy"
|
8
|
+
|
9
|
+
require "orientdb_schema_migrator/railtie" if defined?(Rails)
|
10
|
+
|
11
|
+
module OrientdbSchemaMigrator
|
12
|
+
ODBClient = Orientdb4r.client
|
13
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module OrientdbSchemaMigrator
|
2
|
+
class MigrationError < StandardError; end
|
3
|
+
|
4
|
+
class Migration
|
5
|
+
def self.create_class class_name, class_options={}
|
6
|
+
# check if class exists first
|
7
|
+
assert_class_not_exists!(class_name)
|
8
|
+
ODBClient.create_class class_name, class_options
|
9
|
+
if block_given?
|
10
|
+
proxy = Proxy.new(self, class_name)
|
11
|
+
yield proxy
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.drop_class class_name
|
16
|
+
# check if class exists first
|
17
|
+
if class_exists?(class_name)
|
18
|
+
# delete vertices/edges first
|
19
|
+
super_class = ODBClient.get_class(class_name)["superClass"]
|
20
|
+
if super_class == "V"
|
21
|
+
ODBClient.command "delete vertex #{class_name}"
|
22
|
+
elsif super_class == "E"
|
23
|
+
ODBClient.command "delete edge #{class_name}"
|
24
|
+
end
|
25
|
+
# drop class
|
26
|
+
ODBClient.command "drop class #{class_name}"
|
27
|
+
return true
|
28
|
+
else
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.rename_class old_name, new_name
|
34
|
+
assert_class_exists!(old_name)
|
35
|
+
ODBClient.command "alter class #{old_name} name #{new_name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.add_property class_name, property_name, type, property_options={}
|
39
|
+
assert_class_exists!(class_name)
|
40
|
+
assert_property_not_exists!(class_name, property_name)
|
41
|
+
ODBClient.create_property class_name,property_name,type, property_options
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.drop_property class_name, property_name
|
45
|
+
assert_class_exists!(class_name)
|
46
|
+
assert_property_exists!(class_name, property_name)
|
47
|
+
ODBClient.command "drop property #{class_name}.#{property_name}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.alter_property class_name, property_name, attribute_name, new_value
|
51
|
+
assert_class_exists!(class_name)
|
52
|
+
assert_property_exists!(class_name, property_name)
|
53
|
+
ODBClient.command "alter property #{class_name}.#{property_name} #{attribute_name} #{new_value}"
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.add_index class_name, property_name, index_name, type
|
57
|
+
assert_class_exists!(class_name)
|
58
|
+
assert_property_exists!(class_name, property_name)
|
59
|
+
assert_index_not_exists!(class_name, index_name)
|
60
|
+
ODBClient.command "create index #{index_name} on #{class_name} (#{property_name}) #{type}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.drop_index index_name
|
64
|
+
ODBClient.command "drop index #{index_name}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.class_exists? class_name
|
68
|
+
ODBClient.class_exists? class_name
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.index_exists?(class_name, index_name)
|
72
|
+
return false unless class_exists?(class_name)
|
73
|
+
indexes = ODBClient.get_class(class_name)["indexes"]
|
74
|
+
return false unless indexes
|
75
|
+
return indexes.any? { |idx| idx['name'] == index_name }
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.property_exists? class_name, property_name
|
79
|
+
if class_exists? class_name
|
80
|
+
properties = ODBClient.get_class(class_name)["properties"]
|
81
|
+
if properties
|
82
|
+
return properties.collect{|i| i["name"]}.include? property_name
|
83
|
+
else
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
else
|
87
|
+
return false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.assert_class_exists!(class_name)
|
92
|
+
fail MigrationError.new("Class #{class_name} does not exist") unless class_exists?(class_name)
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.assert_class_not_exists!(class_name)
|
96
|
+
fail MigrationError.new("Class #{class_name} already exists") unless !class_exists?(class_name)
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.assert_property_exists!(class_name, property)
|
100
|
+
fail MigrationError.new("#{class_name}.#{property} does not exist") unless property_exists?(class_name, property)
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.assert_property_not_exists!(class_name, property)
|
104
|
+
fail MigrationError.new("#{class_name}.#{property} already exists") unless !property_exists?(class_name, property)
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.assert_index_not_exists!(class_name, index)
|
108
|
+
fail MigrationError.new("#{class_name},#{index} already exists") unless !index_exists?(class_name, index)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module OrientdbSchemaMigrator
|
5
|
+
class InvalidMigrationName < StandardError; end
|
6
|
+
|
7
|
+
class MigrationGenerator
|
8
|
+
|
9
|
+
class MigrationGeneratorBinding
|
10
|
+
attr_reader :name
|
11
|
+
def initialize(name)
|
12
|
+
@name = name
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_binding
|
16
|
+
binding
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.generate(name, path)
|
21
|
+
create_folder_if_not_exists!(path)
|
22
|
+
mg = new(name, path)
|
23
|
+
mg.write_file
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.create_folder_if_not_exists!(path)
|
27
|
+
return if File.directory?(path)
|
28
|
+
Dir.mkdir(path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def initialize(name, path)
|
32
|
+
@name = name
|
33
|
+
validate_name!
|
34
|
+
time = Time.now.strftime("%Y%m%d%H%M%S")
|
35
|
+
file_name = @name.underscore
|
36
|
+
@file_path = path + "/" + time + "_" + file_name + ".rb"
|
37
|
+
end
|
38
|
+
|
39
|
+
def write_file
|
40
|
+
template_path = File.expand_path("../templates/migration_template.rb", __FILE__)
|
41
|
+
File.open(@file_path, "w", 0644) do |f|
|
42
|
+
f.write ERB.new(File.read(template_path)).result(MigrationGeneratorBinding.new(name).get_binding)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
attr_reader :name
|
49
|
+
|
50
|
+
def validate_name!
|
51
|
+
if name.underscore.camelcase != name
|
52
|
+
fail InvalidMigrationName.new("Name must be convertible between CamelCase and snake_case: #{name}")
|
53
|
+
end
|
54
|
+
if name.match(/[^a-zA-Z]+/)
|
55
|
+
fail InvalidMigrationName.new("Name must consist only of alphabetic characters: #{name}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
|
3
|
+
module OrientdbSchemaMigrator
|
4
|
+
class MigratorConflictError < StandardError; end
|
5
|
+
|
6
|
+
class Migrator
|
7
|
+
@migrations_path = nil
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def migrations_path= path
|
11
|
+
@migrations_path = path
|
12
|
+
end
|
13
|
+
|
14
|
+
def migrations_path
|
15
|
+
@migrations_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def connect_to_db db, user, password
|
19
|
+
ODBClient.connect :database => db, :user => user, :password => password
|
20
|
+
end
|
21
|
+
|
22
|
+
def disconnect
|
23
|
+
ODBClient.disconnect
|
24
|
+
end
|
25
|
+
|
26
|
+
def migrate(target_version = nil)
|
27
|
+
run(:up, target_version)
|
28
|
+
end
|
29
|
+
|
30
|
+
def migrations
|
31
|
+
files = Dir[@migrations_path + '/[0-9]*_*.rb']
|
32
|
+
seen = Hash.new false
|
33
|
+
migrations = files.map do |f|
|
34
|
+
version, name = f.scan(/(\d+)_([^\.]+)/).first
|
35
|
+
if seen[version] || seen[name]
|
36
|
+
fail MigratorConflictError.new("Duplicate migration name/version: #{name}, #{version}")
|
37
|
+
else
|
38
|
+
seen[version] = seen[name] = true
|
39
|
+
end
|
40
|
+
{
|
41
|
+
name: name,
|
42
|
+
version: version,
|
43
|
+
path: f
|
44
|
+
}
|
45
|
+
end
|
46
|
+
migrations.sort_by { |m| m[:version] }
|
47
|
+
end
|
48
|
+
|
49
|
+
def run(command, target_version)
|
50
|
+
new(current_version, target_version, command).migrate
|
51
|
+
end
|
52
|
+
|
53
|
+
def rollback(options = {})
|
54
|
+
new(current_version, nil, nil).rollback
|
55
|
+
end
|
56
|
+
|
57
|
+
def current_version
|
58
|
+
response = ODBClient.command "SELECT schema_version FROM schema_versions ORDER BY @rid DESC LIMIT 1"
|
59
|
+
results = response['result']
|
60
|
+
results.any? ? results.first['schema_version'] : nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def initialize(current_version, target_version, direction)
|
65
|
+
@current_version = current_version
|
66
|
+
@target_version = target_version
|
67
|
+
@direction = direction
|
68
|
+
end
|
69
|
+
|
70
|
+
def migrations
|
71
|
+
return @migrations if defined?(@migrations)
|
72
|
+
if @direction == :down
|
73
|
+
@migrations = self.class.migrations.reverse
|
74
|
+
else
|
75
|
+
@migrations = self.class.migrations
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def migrate
|
80
|
+
migrations[start..finish].each do |m|
|
81
|
+
require m[:path]
|
82
|
+
m[:name].camelize.constantize.public_send(@direction)
|
83
|
+
if up?
|
84
|
+
record_migration(m)
|
85
|
+
else
|
86
|
+
drop_migration(m)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def rollback
|
92
|
+
migrations.find { |m| m[:version] == @current_version }.tap do |m|
|
93
|
+
require m[:path]
|
94
|
+
m[:name].camelize.constantize.down
|
95
|
+
drop_migration(m)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def start
|
102
|
+
@current_version.nil? ? 0 : migrations.find_index { |m| m[:version] == @current_version }
|
103
|
+
end
|
104
|
+
|
105
|
+
def finish
|
106
|
+
@target_version.nil? ? migrations.size - 1 : migrations.find_index { |m| m[:version] == @target_version }
|
107
|
+
end
|
108
|
+
|
109
|
+
def record_migration(migration)
|
110
|
+
ODBClient.command "INSERT INTO schema_versions (schema_version) VALUES (#{migration[:version]})"
|
111
|
+
end
|
112
|
+
|
113
|
+
def drop_migration(migration)
|
114
|
+
ODBClient.command "DELETE FROM schema_versions WHERE schema_version = '#{migration[:version]}'"
|
115
|
+
end
|
116
|
+
|
117
|
+
def up?
|
118
|
+
@direction == :up
|
119
|
+
end
|
120
|
+
|
121
|
+
def down?
|
122
|
+
@direction == :down
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module OrientdbSchemaMigrator
|
2
|
+
class Proxy
|
3
|
+
attr_reader :target, :context
|
4
|
+
|
5
|
+
def initialize(target, context)
|
6
|
+
@target = target
|
7
|
+
@context = context
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_property(property, type, options = {})
|
11
|
+
target.public_send(:add_property, context, property, type, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def alter_property(property, attribute_name, new_value)
|
15
|
+
target.public_send(:add_property, context, property, attribute_name, new_value)
|
16
|
+
end
|
17
|
+
|
18
|
+
def drop_property(property)
|
19
|
+
target.public_send(:add_property, context, property)
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_index(property, index_name, index_type)
|
23
|
+
target.public_send(:add_property, context, property, index_name, index_type)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
namespace :odb do
|
4
|
+
task :config do
|
5
|
+
if !ENV['ODB_TEST']
|
6
|
+
migrations_path =
|
7
|
+
if ENV['odb_migrations_path']
|
8
|
+
migrations_path = ENV['odb_migrations_path']
|
9
|
+
elsif defined?(Rails)
|
10
|
+
Rails.root.to_s + '/db/orientdb/migrate'
|
11
|
+
else
|
12
|
+
raise "No migrations path defined"
|
13
|
+
end
|
14
|
+
|
15
|
+
OrientdbSchemaMigrator::Migrator.migrations_path = migrations_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def with_connection &block
|
20
|
+
config_file =
|
21
|
+
if defined?(Rails)
|
22
|
+
Rails.root.to_s + '/config/orientdb.yml'
|
23
|
+
elsif ENV['ODB_TEST']
|
24
|
+
File.expand_path('../../../spec/support/config.yml', __FILE__)
|
25
|
+
elsif ENV['odb_config_path']
|
26
|
+
ENV['odb_config_path']
|
27
|
+
else
|
28
|
+
raise "No odb config path defined"
|
29
|
+
end
|
30
|
+
|
31
|
+
env =
|
32
|
+
if defined?(Rails)
|
33
|
+
Rails.env
|
34
|
+
elsif ENV['ODB_TEST']
|
35
|
+
'test'
|
36
|
+
else
|
37
|
+
raise "No environment specified to load database connection config"
|
38
|
+
end
|
39
|
+
|
40
|
+
config = YAML.load_file(config_file)[env]
|
41
|
+
OrientdbSchemaMigrator::Migrator.connect_to_db(config['db'], config['user'], config['password'])
|
42
|
+
begin
|
43
|
+
yield
|
44
|
+
ensure
|
45
|
+
OrientdbSchemaMigrator::Migrator.disconnect
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Migrate"
|
50
|
+
task :migrate => [:config] do
|
51
|
+
with_connection do
|
52
|
+
OrientdbSchemaMigrator::Migrator.migrate(ENV['schema_version'])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Rollback one migration"
|
57
|
+
task :rollback => [:config] do
|
58
|
+
with_connection do
|
59
|
+
OrientdbSchemaMigrator::Migrator.rollback(ENV['schema_version'])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Generate a new migration"
|
64
|
+
task :generate_migration => [:config] do
|
65
|
+
OrientdbSchemaMigrator::MigrationGenerator.generate(ENV['migration_name'], OrientdbSchemaMigrator::Migrator.migrations_path)
|
66
|
+
end
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: orientdb-schema-migrator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- CoPromote
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: orientdb4r
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: climate_control
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.0.3
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.0.3
|
111
|
+
description: Migrate OrientDB schema
|
112
|
+
email:
|
113
|
+
- info@copromote.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- LICENSE
|
119
|
+
- README.md
|
120
|
+
- Rakefile
|
121
|
+
- lib/orientdb-schema-migrator.rb
|
122
|
+
- lib/orientdb_schema_migrator/migration.rb
|
123
|
+
- lib/orientdb_schema_migrator/migration_generator.rb
|
124
|
+
- lib/orientdb_schema_migrator/migrator.rb
|
125
|
+
- lib/orientdb_schema_migrator/proxy.rb
|
126
|
+
- lib/orientdb_schema_migrator/railtie.rb
|
127
|
+
- lib/orientdb_schema_migrator/templates/migration_template.rb
|
128
|
+
- lib/orientdb_schema_migrator/version.rb
|
129
|
+
- lib/tasks/orientdb_schema_migrator.rake
|
130
|
+
homepage: https://copromote.com
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.2.2
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Migrate OrientDB schema
|
154
|
+
test_files: []
|