migrate-hack 0.2.0 → 0.2.1
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/bin/migrate-hack.sh +63 -38
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dc2a35a68c4b43f0800a4ffc33e3c5da9d7e6307940183f4d713c82c7e9fb56
|
4
|
+
data.tar.gz: 74d254de5fc9e31981892a6c3bb869cfad2d04d0cecbc2bb596988d5c54699b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72da583afab23fb33910d78df230432324a1ad9487806aa78b8b36878165aabdd1ae57aeb1c2386175440fe01812689042fe0aeb298717ac242b0a636486331e
|
7
|
+
data.tar.gz: b6c01d2b095e8ad6bed6d18841f3c6ced40e856de8ff7574bf9bee31e144094bfc8b294097cb7262849c0b484471776694ba27463a6b8b27c03fb6c58451ee34
|
data/bin/migrate-hack.sh
CHANGED
@@ -1,9 +1,57 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
+
# This script is designed to run pending migrations in a Rails application
|
4
|
+
# by checking out the commit where each migration was created.
|
5
|
+
# It also allows loading environment variables from a specified file and
|
6
|
+
# copying files from a specified directory to the current one.
|
7
|
+
# Usage: ./migrate-hack.sh [--env=FILE] [--copy=DIR] [--help] [--version]
|
8
|
+
|
9
|
+
VERSION="0.2.1"
|
3
10
|
ENV_FILE=""
|
4
11
|
COPY_DIR=""
|
5
12
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
6
13
|
|
14
|
+
# GETTING ARGS
|
15
|
+
while [[ $# -gt 0 ]]; do
|
16
|
+
key="$1"
|
17
|
+
case $key in
|
18
|
+
--env)
|
19
|
+
ENV_FILE="$2"
|
20
|
+
shift 2
|
21
|
+
;;
|
22
|
+
--env=*)
|
23
|
+
ENV_FILE="${key#*=}"
|
24
|
+
shift
|
25
|
+
;;
|
26
|
+
--copy)
|
27
|
+
COPY_DIR="$2"
|
28
|
+
shift 2
|
29
|
+
;;
|
30
|
+
--copy=*)
|
31
|
+
COPY_DIR="${key#*=}"
|
32
|
+
shift
|
33
|
+
;;
|
34
|
+
--help)
|
35
|
+
echo "Usage: migrate-hack [--env=FILE] [--copy=DIR] [--help] [--version]"
|
36
|
+
echo ""
|
37
|
+
echo "Options:"
|
38
|
+
echo " --env=FILE Load environment variables from the specified file"
|
39
|
+
echo " --copy=DIR Copy config and settings untracked files from the specified directory to the current one"
|
40
|
+
echo " --help Show this help message"
|
41
|
+
echo " --version Show script version"
|
42
|
+
exit 0
|
43
|
+
;;
|
44
|
+
--version)
|
45
|
+
echo "migrate-hack ($VERSION)"
|
46
|
+
exit 0
|
47
|
+
;;
|
48
|
+
*)
|
49
|
+
echo "[debug] Ignoring unknown argument: $1"
|
50
|
+
shift
|
51
|
+
;;
|
52
|
+
esac
|
53
|
+
done
|
54
|
+
|
7
55
|
renew_git() {
|
8
56
|
if [[ -n $(git status --porcelain) ]]; then
|
9
57
|
git stash -u > /dev/null
|
@@ -11,6 +59,19 @@ renew_git() {
|
|
11
59
|
fi
|
12
60
|
}
|
13
61
|
|
62
|
+
copy_files() {
|
63
|
+
if [ -n "$COPY_DIR" ]; then
|
64
|
+
destination=$(pwd)
|
65
|
+
if [ -d "$COPY_DIR" ]; then
|
66
|
+
echo "[copy] Copying files from $COPY_DIR to $destination..."
|
67
|
+
cp -r "$COPY_DIR/." "$destination"
|
68
|
+
else
|
69
|
+
echo "[copy] Directory not found: $COPY_DIR"
|
70
|
+
exit 1
|
71
|
+
fi
|
72
|
+
fi
|
73
|
+
}
|
74
|
+
|
14
75
|
# BLOCKS
|
15
76
|
|
16
77
|
# UNCOMITTED CHANGES
|
@@ -39,33 +100,6 @@ if [ -f tmp/pids/server.pid ]; then
|
|
39
100
|
fi
|
40
101
|
fi
|
41
102
|
|
42
|
-
# GETTING ARGS
|
43
|
-
while [[ $# -gt 0 ]]; do
|
44
|
-
key="$1"
|
45
|
-
case $key in
|
46
|
-
--env)
|
47
|
-
ENV_FILE="$2"
|
48
|
-
shift 2
|
49
|
-
;;
|
50
|
-
--env=*)
|
51
|
-
ENV_FILE="${key#*=}"
|
52
|
-
shift
|
53
|
-
;;
|
54
|
-
--copy)
|
55
|
-
COPY_DIR="$2"
|
56
|
-
shift 2
|
57
|
-
;;
|
58
|
-
--copy=*)
|
59
|
-
COPY_DIR="${key#*=}"
|
60
|
-
shift
|
61
|
-
;;
|
62
|
-
*)
|
63
|
-
echo "[debug] Ignoring unknown argument: $1"
|
64
|
-
shift
|
65
|
-
;;
|
66
|
-
esac
|
67
|
-
done
|
68
|
-
|
69
103
|
# LOAD ENVIRONMENT
|
70
104
|
if [ -n "$ENV_FILE" ]; then
|
71
105
|
echo "[env] Loading environment from $ENV_FILE"
|
@@ -75,16 +109,7 @@ if [ -n "$ENV_FILE" ]; then
|
|
75
109
|
fi
|
76
110
|
|
77
111
|
# COPY FILES
|
78
|
-
|
79
|
-
destination=$(pwd)
|
80
|
-
if [ -d "$COPY_DIR" ]; then
|
81
|
-
echo "[copy] Copying files from $COPY_DIR to $destination..."
|
82
|
-
cp -r "$COPY_DIR/." "$destination"
|
83
|
-
else
|
84
|
-
echo "[copy] Directory not found: $COPY_DIR"
|
85
|
-
exit 1
|
86
|
-
fi
|
87
|
-
fi
|
112
|
+
copy_files
|
88
113
|
|
89
114
|
echo "Detecting pending migrations..."
|
90
115
|
|
@@ -110,7 +135,7 @@ while read -r TIMESTAMP MIGRATION COMMIT; do
|
|
110
135
|
renew_git
|
111
136
|
CHECKOUT=$(git -c advice.detachedHead=false checkout "$COMMIT")
|
112
137
|
|
113
|
-
|
138
|
+
copy_files
|
114
139
|
|
115
140
|
bundle install > /dev/null
|
116
141
|
echo -e "\033[1;32m - migrate\033[0m"
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migrate-hack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Zillner
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-04-01 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
|
-
description: "
|
13
|
-
|
12
|
+
description: "Run any amount of migrations. migrate-hack fixes your migrations. This
|
13
|
+
gem rewinds your commits to apply migrations safely, and then puts everything back
|
14
|
+
the way it was. This fixes a bunch of common issues.\n\n"
|
14
15
|
email:
|
15
16
|
- carlos@function.ws
|
16
17
|
executables:
|