-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathfix-migrations-simple.sh
More file actions
executable file
Β·47 lines (38 loc) Β· 1.54 KB
/
fix-migrations-simple.sh
File metadata and controls
executable file
Β·47 lines (38 loc) Β· 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Simple Migration Fix Script
# This marks all existing migrations as applied with dummy checksums
set -e
DB_NAME="aframp"
echo "π§ Fixing migration state for $DB_NAME..."
echo ""
# Check if database exists
if ! psql -lqt | cut -d \| -f 1 | grep -qw "$DB_NAME"; then
echo "β Database $DB_NAME does not exist"
echo "Run: createdb $DB_NAME"
exit 1
fi
echo "π Current state:"
psql -d "$DB_NAME" -c "SELECT version, description FROM _sqlx_migrations ORDER BY version;" 2>/dev/null || echo "No migrations tracked yet"
echo ""
echo "ποΈ Clearing migration tracking..."
psql -d "$DB_NAME" -c "DELETE FROM _sqlx_migrations;" > /dev/null
echo "π Marking migrations as applied..."
psql -d "$DB_NAME" << 'EOF' > /dev/null
INSERT INTO _sqlx_migrations (version, description, success, checksum, execution_time, installed_on)
VALUES
(20260122120000, 'create core schema', true, E'\\x00', 0, now()),
(20260123040000, 'implement payments schema', true, E'\\x00', 0, now()),
(20260124000000, 'indexes and constraints', true, E'\\x00', 0, now());
EOF
echo ""
echo "β
Migration state fixed!"
echo ""
echo "π Updated state:"
psql -d "$DB_NAME" -c "SELECT version, description, success FROM _sqlx_migrations ORDER BY version;"
echo ""
echo "β οΈ Note: Checksums are set to dummy values (0x00)."
echo "This is OK for development. The database schema is correct."
echo ""
echo "You can now:"
echo " 1. Run ./setup.sh (it will skip migrations since they're marked as applied)"
echo " 2. Start the server: cargo run --features database"