migrate-hack 0.1.4 → 0.1.5
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 +12 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 874ef296521001a221bd359339e293ed9642cce1766576f7898288e86359ec24
|
4
|
+
data.tar.gz: 15073d4e18ec808748fe9b11261376031b0fba0a4a92e7b2fd6230db0419be5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d77f1ed113875d78a62c3173a3af6dfcfdfa826cd5dd2a107ce1da3f5a60553977a6e0ec93f0e519814caaa56aa737d538e5e820ba6a4ed8cdd74fa1007a966f
|
7
|
+
data.tar.gz: da92430bd921647d493c7c3d2f263818dcfcee1a88398d6958c8c78317f291c167c3ff260841376d5b263c3b00c39ed53ced4801a010f03010f86d6faebacca8
|
data/bin/migrate-hack.sh
CHANGED
@@ -3,6 +3,13 @@
|
|
3
3
|
ENV_FILE=""
|
4
4
|
COPY_DIR=""
|
5
5
|
|
6
|
+
renew_git() {
|
7
|
+
if [[ -n $(git status --porcelain) ]]; then
|
8
|
+
git stash -u > /dev/null
|
9
|
+
git stash drop > /dev/null
|
10
|
+
fi
|
11
|
+
}
|
12
|
+
|
6
13
|
if [[ -n $(git status --porcelain) ]]; then
|
7
14
|
echo "[error] There are modified, deleted, or untracked files in the repository. Please resolve these changes before continuing."
|
8
15
|
exit 1
|
@@ -56,12 +63,11 @@ echo "Detecting pending migrations..."
|
|
56
63
|
|
57
64
|
# 1. Get pending migrations list
|
58
65
|
PENDING_MIGRATIONS=$(bundle exec rails db:migrate:status | grep down | awk '{ print $2 }')
|
66
|
+
echo -e "\033[1;32mPending Migrations:\033[0m"
|
67
|
+
echo $PENDING_MIGRATIONS
|
59
68
|
|
60
69
|
# 2. [commit_date] [migration_id] [commit_hash]
|
61
70
|
MIGRATION_LIST=""
|
62
|
-
|
63
|
-
echo "Pending Migrations: $PENDING_MIGRATIONS"
|
64
|
-
|
65
71
|
TEMP_FILE=$(mktemp)
|
66
72
|
|
67
73
|
# Build the file
|
@@ -73,10 +79,9 @@ for MIGRATION in $PENDING_MIGRATIONS; do
|
|
73
79
|
done
|
74
80
|
|
75
81
|
# 3. Order list by commit date
|
76
|
-
cat $TEMP_FILE
|
77
|
-
|
78
82
|
while read -r TIMESTAMP MIGRATION COMMIT; do
|
79
83
|
echo -e "\033[1;32mRunning migration $MIGRATION on commit $COMMIT (timestamp $TIMESTAMP)...\033[0m"
|
84
|
+
renew_git
|
80
85
|
CHECKOUT=$(git -c advice.detachedHead=false checkout "$COMMIT")
|
81
86
|
|
82
87
|
cp -r "$COPY_DIR/." "$destination"
|
@@ -85,18 +90,11 @@ while read -r TIMESTAMP MIGRATION COMMIT; do
|
|
85
90
|
echo -e "\033[1;32m - migrate\033[0m"
|
86
91
|
bundle exec rails db:migrate:up VERSION=$MIGRATION
|
87
92
|
|
88
|
-
|
89
|
-
git stash -u > /dev/null
|
90
|
-
git stash drop > /dev/null
|
91
|
-
fi
|
93
|
+
renew_git
|
92
94
|
git checkout main > /dev/null
|
93
95
|
done < <(sort -n "$TEMP_FILE")
|
94
96
|
|
95
|
-
|
96
|
-
git stash -u > /dev/null
|
97
|
-
git stash drop > /dev/null
|
98
|
-
fi
|
99
|
-
|
97
|
+
renew_git
|
100
98
|
bundle exec rails db:migrate:status | grep down
|
101
99
|
|
102
100
|
# 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.5
|
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.
|