migrate-hack 0.1.4 → 0.1.6
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 +14 -15
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44f2ca633929442ab8392803285d38427944836b0cf9a63597cd2b97477efc33
|
4
|
+
data.tar.gz: 1568f071e4d9677ed30b90af081eee0cc03d2b8fcaab8c526b65a54d021e5e83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b884c68b4e60a45be692e19a129f559a1cf67da6a5834ccc9dc3675fc1028f12835e06b62c6b0d0bab5f2e89f49b746a72c6acaffe77974c6fec6bd1deb3a244
|
7
|
+
data.tar.gz: bbf1620055e63e353c0d3304d114553be47dac84cd0d4f74263f9d0c85c0a52890e2003afb3e3d644c5da853b6efe9d890ee5c1cff7d92ddb90162dc6a2669df
|
data/bin/migrate-hack.sh
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
ENV_FILE=""
|
4
4
|
COPY_DIR=""
|
5
|
+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
6
|
+
|
7
|
+
renew_git() {
|
8
|
+
if [[ -n $(git status --porcelain) ]]; then
|
9
|
+
git stash -u > /dev/null
|
10
|
+
git stash drop > /dev/null
|
11
|
+
fi
|
12
|
+
}
|
5
13
|
|
6
14
|
if [[ -n $(git status --porcelain) ]]; then
|
7
15
|
echo "[error] There are modified, deleted, or untracked files in the repository. Please resolve these changes before continuing."
|
@@ -56,12 +64,11 @@ echo "Detecting pending migrations..."
|
|
56
64
|
|
57
65
|
# 1. Get pending migrations list
|
58
66
|
PENDING_MIGRATIONS=$(bundle exec rails db:migrate:status | grep down | awk '{ print $2 }')
|
67
|
+
echo -e "\033[1;32mPending Migrations:\033[0m"
|
68
|
+
echo $PENDING_MIGRATIONS
|
59
69
|
|
60
70
|
# 2. [commit_date] [migration_id] [commit_hash]
|
61
71
|
MIGRATION_LIST=""
|
62
|
-
|
63
|
-
echo "Pending Migrations: $PENDING_MIGRATIONS"
|
64
|
-
|
65
72
|
TEMP_FILE=$(mktemp)
|
66
73
|
|
67
74
|
# Build the file
|
@@ -73,10 +80,9 @@ for MIGRATION in $PENDING_MIGRATIONS; do
|
|
73
80
|
done
|
74
81
|
|
75
82
|
# 3. Order list by commit date
|
76
|
-
cat $TEMP_FILE
|
77
|
-
|
78
83
|
while read -r TIMESTAMP MIGRATION COMMIT; do
|
79
84
|
echo -e "\033[1;32mRunning migration $MIGRATION on commit $COMMIT (timestamp $TIMESTAMP)...\033[0m"
|
85
|
+
renew_git
|
80
86
|
CHECKOUT=$(git -c advice.detachedHead=false checkout "$COMMIT")
|
81
87
|
|
82
88
|
cp -r "$COPY_DIR/." "$destination"
|
@@ -85,18 +91,11 @@ while read -r TIMESTAMP MIGRATION COMMIT; do
|
|
85
91
|
echo -e "\033[1;32m - migrate\033[0m"
|
86
92
|
bundle exec rails db:migrate:up VERSION=$MIGRATION
|
87
93
|
|
88
|
-
|
89
|
-
|
90
|
-
git stash drop > /dev/null
|
91
|
-
fi
|
92
|
-
git checkout main > /dev/null
|
94
|
+
renew_git
|
95
|
+
git checkout $CURRENT_BRANCH > /dev/null
|
93
96
|
done < <(sort -n "$TEMP_FILE")
|
94
97
|
|
95
|
-
|
96
|
-
git stash -u > /dev/null
|
97
|
-
git stash drop > /dev/null
|
98
|
-
fi
|
99
|
-
|
98
|
+
renew_git
|
100
99
|
bundle exec rails db:migrate:status | grep down
|
101
100
|
|
102
101
|
# Remove temp file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migrate-hack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Zillner
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-26 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: |+
|
13
13
|
Ideal for deterministic pipelines, CI/CD, or containers that apply migrations step by step.
|
@@ -32,6 +32,7 @@ licenses:
|
|
32
32
|
- MIT
|
33
33
|
metadata:
|
34
34
|
source_code_uri: https://github.com/omelao/migrate-hack
|
35
|
+
changelog_uri: https://github.com/omelao/migrate-hack/blob/main/CHANGELOG.md
|
35
36
|
rdoc_options: []
|
36
37
|
require_paths:
|
37
38
|
- lib
|