unschema 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +18 -6
- data/Gemfile +4 -0
- data/README.md +17 -2
- data/lib/unschema/base.rb +29 -14
- data/lib/unschema/migration_dumper.rb +1 -1
- data/lib/unschema/schema_intermediator.rb +4 -0
- data/lib/unschema/version.rb +1 -1
- data/test/helper.rb +6 -1
- data/unschema.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2686bd6b60b612e83c1fe9cb918cdf590b9dcfe2
|
4
|
+
data.tar.gz: 62b58128cf9cf22570d5d9b3ed06b06577289cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce6fa5ae2759ba765ca70bc7d215581031bb7db0177ce7bb29266dc17251923d42c3f2e1f9f434be844bf2a24fcab2dd5cede14f0bf7a594ffb4e231e93c60b9
|
7
|
+
data.tar.gz: b23aeb38e84fe1681ad5cc533ede0e7a4154b30632a4f89a8480f295f6402b901aaa36011d5fccd751002f739918275c91afe6b56486d8654c2befeaa8211b76
|
data/.travis.yml
CHANGED
@@ -1,12 +1,24 @@
|
|
1
1
|
language: ruby
|
2
|
+
sudo: false
|
3
|
+
cache: bundler
|
2
4
|
rvm:
|
3
|
-
-
|
4
|
-
-
|
5
|
-
-
|
6
|
-
-
|
5
|
+
- ruby-head
|
6
|
+
- 2.2
|
7
|
+
- 2.1
|
8
|
+
- 2.0
|
9
|
+
- 1.9.3
|
10
|
+
env:
|
11
|
+
global:
|
12
|
+
- CODECLIMATE_REPO_TOKEN=5149a81a58ceefa61850827c29b5fecc303d15c038b7ad4fb12e8279d2be47ab
|
7
13
|
matrix:
|
8
14
|
fast_finish: true
|
9
15
|
allow_failures:
|
10
|
-
- jruby-head
|
11
16
|
- ruby-head
|
12
|
-
|
17
|
+
|
18
|
+
notifications:
|
19
|
+
webhooks:
|
20
|
+
urls:
|
21
|
+
- https://webhooks.gitter.im/e/d347d6c0296c3caf01ad
|
22
|
+
on_success: change # options: [always|never|change] default: always
|
23
|
+
on_failure: always # options: [always|never|change] default: always
|
24
|
+
on_start: false # default: false
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,24 @@
|
|
1
|
-
|
1
|
+
[github]: https://github.com/neopoly/unschema
|
2
|
+
[doc]: http://rubydoc.info/github/neopoly/unschema/master/file/README.md
|
3
|
+
[gem]: https://rubygems.org/gems/unschema
|
4
|
+
[travis]: https://travis-ci.org/neopoly/unschema
|
5
|
+
[codeclimate]: https://codeclimate.com/github/neopoly/unschema
|
6
|
+
[inchpages]: https://inch-ci.org/github/neopoly/unschema
|
2
7
|
|
3
|
-
|
8
|
+
# Unschema - rebase your schema.rb
|
4
9
|
|
5
10
|
Splits your schema.rb into separate migrations per table.
|
6
11
|
|
12
|
+
[![Travis](https://img.shields.io/travis/neopoly/unschema.svg?branch=master)][travis]
|
13
|
+
[![Gem Version](https://img.shields.io/gem/v/unschema.svg)][gem]
|
14
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/neopoly/unschema.svg)][codeclimate]
|
15
|
+
[![Test Coverage](https://codeclimate.com/github/neopoly/unschema/badges/coverage.svg)][codeclimate]
|
16
|
+
[![Inline docs](https://inch-ci.org/github/neopoly/unschema.svg?branch=master&style=flat)][inchpages]
|
17
|
+
|
18
|
+
[Gem][gem] |
|
19
|
+
[Source][github] |
|
20
|
+
[Documentation][doc]
|
21
|
+
|
7
22
|
Every table migration contains a create_table and additional add_index calls.
|
8
23
|
|
9
24
|
We use it to cleanup older projects, that gets reused as codebase for new projects.
|
data/lib/unschema/base.rb
CHANGED
@@ -10,29 +10,44 @@ module Unschema
|
|
10
10
|
|
11
11
|
def process
|
12
12
|
load schema_file
|
13
|
+
preset_version
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
calls_for_tables = Hash.new{|hash, key| hash[key] = []}
|
17
|
-
|
18
|
-
ActiveRecord::Schema.intermediator.calls.each do |call|
|
19
|
-
table_name = call.args.first.to_s if [:create_table, :add_index].include?(call.name)
|
20
|
-
raise "Don't now how to process #{call.name.inspect}" unless table_name
|
21
|
-
|
22
|
-
calls_for_tables[table_name] << call
|
23
|
-
end
|
24
|
-
|
25
|
-
puts "Found #{calls_for_tables.keys.size} tables" if verbose?
|
15
|
+
calls_for_tables = collect_calls(intermediator.calls)
|
16
|
+
log "Found #{calls_for_tables.size} tables"
|
26
17
|
|
27
18
|
calls_for_tables.sort.each do |table_name, calls|
|
28
|
-
|
19
|
+
log " Dumping #{table_name.inspect}"
|
29
20
|
dump_table_calls table_name, calls
|
30
21
|
end
|
31
|
-
|
22
|
+
|
23
|
+
log "Done"
|
32
24
|
end
|
33
25
|
|
34
26
|
private
|
35
27
|
|
28
|
+
def log(string)
|
29
|
+
puts string if verbose?
|
30
|
+
end
|
31
|
+
|
32
|
+
def preset_version
|
33
|
+
@version = intermediator.version
|
34
|
+
end
|
35
|
+
|
36
|
+
def intermediator
|
37
|
+
ActiveRecord::Schema.intermediator
|
38
|
+
end
|
39
|
+
|
40
|
+
def collect_calls(calls)
|
41
|
+
calls_for_tables = Hash.new { |hash, key| hash[key] = [] }
|
42
|
+
|
43
|
+
calls.each do |call|
|
44
|
+
table_name = call.first_arg
|
45
|
+
calls_for_tables[table_name] << call
|
46
|
+
end
|
47
|
+
|
48
|
+
calls_for_tables
|
49
|
+
end
|
50
|
+
|
36
51
|
def dump_table_calls(table_name, calls)
|
37
52
|
file = File.join(migrations_path, "#{next_migration}_create_#{table_name}.rb")
|
38
53
|
File.open(file, "w") do |f|
|
data/lib/unschema/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
+
if ENV['CODECLIMATE_REPO_TOKEN']
|
2
|
+
require "codeclimate-test-reporter"
|
3
|
+
CodeClimate::TestReporter.start
|
4
|
+
end
|
5
|
+
|
1
6
|
require 'minitest/autorun'
|
2
7
|
|
3
8
|
require 'unschema'
|
4
9
|
|
5
10
|
class TestCase < Minitest::Test
|
6
11
|
def assert_string(actual, expect)
|
7
|
-
assert_equal expect.unindent
|
12
|
+
assert_equal expect.unindent, actual.unindent
|
8
13
|
end
|
9
14
|
end
|
10
15
|
|
data/unschema.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unschema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Holderbaum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 5.
|
33
|
+
version: '5.5'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 5.
|
40
|
+
version: '5.5'
|
41
41
|
description: Splits your current schema.rb into per-table migrations. Think of it
|
42
42
|
as >rebase< for your migrations.
|
43
43
|
email:
|