farfugl 0.0.3 → 0.0.4
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/README.md +4 -4
- data/farfugl.gemspec +1 -1
- data/lib/farfugl.rb +7 -26
- data/lib/git.rb +21 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7116238b0be5b5478c2cb4707ee16825647d60f5
|
4
|
+
data.tar.gz: 1a1467abc1660f2a312a7f75c13937f6ec28779c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a7d72d4bdafe2b602acb77490af4a6fdd79752d427cbdd11384e065b42f164761342282ef14493e2760cb201621ad85e2cd70ca6baac00e599c255d1ecc093
|
7
|
+
data.tar.gz: 3ae0dca5851be6c93e5ad335cf6adc212063fa7dea3f876a6d0f69472f8d9b604dcb795fb020f7f9686b04f729de9c416ecbe5f86cd13309afaa036af306b92f
|
data/README.md
CHANGED
@@ -9,10 +9,7 @@ application. The simplest solution is to checkout to the commit where each
|
|
9
9
|
migration was introduced (or last modified) and run each migration from there,
|
10
10
|
but this can be time-consuming and tedious. **Farfugl** automates this process.
|
11
11
|
|
12
|
-
|
13
|
-
stable; always create backups your database before using it.
|
14
|
-
|
15
|
-
### Install
|
12
|
+
### Setup
|
16
13
|
|
17
14
|
You can install **Farfugl** on your system like any other gem:
|
18
15
|
|
@@ -23,4 +20,7 @@ You can also add `gem 'farfugl'` to your Rails application's Gemfile and run
|
|
23
20
|
|
24
21
|
### Usage
|
25
22
|
|
23
|
+
Please note that **Farfugl** is still under development and *may* not be
|
24
|
+
completely stable; always create backups of your database before using it.
|
25
|
+
|
26
26
|
rake farfugl
|
data/farfugl.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'farfugl'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.4'
|
4
4
|
s.date = '2014-01-20'
|
5
5
|
s.summary = 'Run old Rails migrations without code dependence problems'
|
6
6
|
s.description = 'Run old Rails migrations without code dependence problems'
|
data/lib/farfugl.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'farfugl/railtie' if defined? Rails
|
2
|
+
require 'git'
|
2
3
|
|
3
4
|
module Farfugl
|
4
5
|
def self.schema_versions
|
@@ -20,41 +21,21 @@ module Farfugl
|
|
20
21
|
migrations
|
21
22
|
end
|
22
23
|
|
23
|
-
def self.hash(file)
|
24
|
-
`git log -n 1 -- #{file}`.split[1]
|
25
|
-
end
|
26
|
-
|
27
24
|
def self.hashes(migrations)
|
28
|
-
migrations.map { |file|
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.stash
|
32
|
-
`git stash -u`
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.unstash
|
36
|
-
`git stash pop`
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.current_branch
|
40
|
-
`git rev-parse --abbrev-ref HEAD`
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.checkout(destination)
|
44
|
-
`git checkout -f #{destination}`
|
25
|
+
migrations.map { |file| Git.hash(file) }
|
45
26
|
end
|
46
27
|
|
47
28
|
def self.migrate
|
48
|
-
|
49
|
-
original_branch =
|
29
|
+
Git.stash
|
30
|
+
original_branch = Git.current_branch
|
50
31
|
hashes = self.hashes(self.pending_migrations(self.schema_versions))
|
51
32
|
hashes.each do |commit_hash|
|
52
|
-
|
33
|
+
Git.checkout(commit_hash)
|
53
34
|
Rake::Task['db:migrate'].invoke
|
54
35
|
Rake::Task['db:migrate'].reenable
|
55
36
|
end
|
56
|
-
|
57
|
-
|
37
|
+
Git.checkout(original_branch)
|
38
|
+
Git.unstash
|
58
39
|
Rake::Task['db:schema:dump'].invoke
|
59
40
|
end
|
60
41
|
end
|
data/lib/git.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Git
|
2
|
+
def self.hash(file)
|
3
|
+
`git log -n 1 -- #{file}`.split[1]
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.stash
|
7
|
+
`git stash -u`
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.unstash
|
11
|
+
`git stash pop`
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.current_branch
|
15
|
+
`git rev-parse --abbrev-ref HEAD`
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.checkout(destination)
|
19
|
+
`git checkout -f #{destination}`
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: farfugl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Haukur Páll Hallvarðsson
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- lib/farfugl.rb
|
23
23
|
- lib/farfugl/railtie.rb
|
24
24
|
- lib/farfugl/tasks/farfugl.rb
|
25
|
+
- lib/git.rb
|
25
26
|
homepage: https://github.com/hph/farfugl
|
26
27
|
licenses:
|
27
28
|
- MIT
|