migrate-hack 0.1.3 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/migrate-hack.sh +17 -15
  3. metadata +8 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75b30fd22d05d321481f2a999869e390590ca4ea4b19ca4894129804683e6fc3
4
- data.tar.gz: 2aade6f3312e932e1b6890f8a2e61276d9f2f9a955d248e13010f53c7f52269d
3
+ metadata.gz: 874ef296521001a221bd359339e293ed9642cce1766576f7898288e86359ec24
4
+ data.tar.gz: 15073d4e18ec808748fe9b11261376031b0fba0a4a92e7b2fd6230db0419be5a
5
5
  SHA512:
6
- metadata.gz: 4600ede448f5cef313151007e022189d8981228f6675a76ff223b305a78983a7601fed7fcb5328cac05c3c25f756c1db2b98058d941460375aba3ae2e7bc0009
7
- data.tar.gz: fe28c1d324d7384b3c16c88c69449138d7c27b40229b90b9bfe7a7935d09a4100b5231a0eefa2204ee36e702275fb1347816297211bf118023986a7819ab7ab3
6
+ metadata.gz: d77f1ed113875d78a62c3173a3af6dfcfdfa826cd5dd2a107ce1da3f5a60553977a6e0ec93f0e519814caaa56aa737d538e5e820ba6a4ed8cdd74fa1007a966f
7
+ data.tar.gz: da92430bd921647d493c7c3d2f263818dcfcee1a88398d6958c8c78317f291c167c3ff260841376d5b263c3b00c39ed53ced4801a010f03010f86d6faebacca8
data/bin/migrate-hack.sh CHANGED
@@ -3,6 +3,18 @@
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
+
13
+ if [[ -n $(git status --porcelain) ]]; then
14
+ echo "[error] There are modified, deleted, or untracked files in the repository. Please resolve these changes before continuing."
15
+ exit 1
16
+ fi
17
+
6
18
  while [[ $# -gt 0 ]]; do
7
19
  key="$1"
8
20
  case $key in
@@ -47,21 +59,15 @@ if [ -n "$COPY_DIR" ]; then
47
59
  fi
48
60
  fi
49
61
 
50
- if [[ -n $(git status --porcelain) ]]; then
51
- echo "[error] There are modified, deleted, or untracked files in the repository. Please resolve these changes before continuing."
52
- exit 1
53
- fi
54
-
55
62
  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,14 +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
- git stash -u > /dev/null
89
- git stash drop > /dev/null
93
+ renew_git
90
94
  git checkout main > /dev/null
91
95
  done < <(sort -n "$TEMP_FILE")
92
96
 
93
- git stash -u > /dev/null
94
- git checkout main > /dev/null
95
-
97
+ renew_git
96
98
  bundle exec rails db:migrate:status | grep down
97
99
 
98
100
  # Remove temp file
metadata CHANGED
@@ -1,20 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: migrate-hack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
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-25 00:00:00.000000000 Z
10
+ date: 2025-03-26 00:00:00.000000000 Z
11
11
  dependencies: []
12
- description: |
12
+ description: |+
13
13
  Ideal for deterministic pipelines, CI/CD, or containers that apply migrations step by step.
14
+
14
15
  --------------------------------
15
- ⚠️ Warning: This gem modifies the files in the repository where it is executed but then restores everything to normal.
16
+
17
+ ⚠️ Warning: This gem modifies the files in the repository where it is executed according to git history, but then restores everything to normal.
16
18
  Do not run it on servers that are actively serving the application.
17
19
  Run it in parallel.
20
+
18
21
  email:
19
22
  - carlos@function.ws
20
23
  executables:
@@ -47,3 +50,4 @@ rubygems_version: 3.6.6
47
50
  specification_version: 4
48
51
  summary: Runs old migrations without conflicts
49
52
  test_files: []
53
+ ...