Skip to content

Commit 1e06e2b

Browse files
committed
Remove Auto Migrate
1 parent 67080a7 commit 1e06e2b

File tree

7 files changed

+77
-402
lines changed

7 files changed

+77
-402
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</p>
1212

1313
> [!IMPORTANT]
14-
> **Upgrading to v3?** Please read the [Migration Guide](MIGRATION_GUIDE.md) for breaking changes and upgrade instructions.
14+
> **Upgrading to v3?** v3 requires a fresh start with a new data volume. Please read the [Upgrade Guide](UPGRADE.md) for instructions.
1515
1616

1717
## 🚀 Quick Start
@@ -35,7 +35,7 @@ First user signup becomes admin. Configure GitHub and Gitea through the web inte
3535
- 🔁 Mirror public, private, and starred GitHub repos to Gitea
3636
- 🏢 Mirror entire organizations with flexible strategies
3737
- 🎯 Custom destination control for repos and organizations
38-
- 🔐 Secure authentication with JWT tokens
38+
- 🔐 Secure authentication with Better Auth (email/password, SSO, OIDC)
3939
- 📊 Real-time dashboard with activity logs
4040
- ⏱️ Scheduled automatic mirroring
4141
- 🐳 Dockerized with multi-arch support (AMD64/ARM64)

UPGRADE.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Upgrade Guide
2+
3+
## Upgrading to v3.0
4+
5+
> **⚠️ IMPORTANT**: v3.0 requires a fresh start. There is no automated migration from v2.x to v3.0.
6+
7+
### Why No Migration?
8+
9+
v3.0 introduces fundamental changes to the application architecture:
10+
- **Authentication**: Switched from JWT to Better Auth
11+
- **Database**: Now uses Drizzle ORM with proper migrations
12+
- **Security**: All tokens are now encrypted
13+
- **Features**: Added SSO support and OIDC provider functionality
14+
15+
Due to these extensive changes, we recommend starting fresh with v3.0 for the best experience.
16+
17+
### Upgrade Steps
18+
19+
1. **Stop your v2.x container**
20+
```bash
21+
docker stop gitea-mirror
22+
docker rm gitea-mirror
23+
```
24+
25+
2. **Backup your v2.x data (optional)**
26+
```bash
27+
# If you want to keep your v2 data for reference
28+
docker run --rm -v gitea-mirror-data:/data -v $(pwd):/backup alpine tar czf /backup/gitea-mirror-v2-backup.tar.gz -C /data .
29+
```
30+
31+
3. **Create a new volume for v3**
32+
```bash
33+
docker volume create gitea-mirror-v3-data
34+
```
35+
36+
4. **Run v3 with the new volume**
37+
```bash
38+
docker run -d \
39+
--name gitea-mirror \
40+
-p 4321:4321 \
41+
-v gitea-mirror-v3-data:/app/data \
42+
-e BETTER_AUTH_SECRET=your-secret-key \
43+
-e ENCRYPTION_SECRET=your-encryption-key \
44+
arunavo4/gitea-mirror:latest
45+
```
46+
47+
5. **Set up your configuration again**
48+
- Navigate to http://localhost:4321
49+
- Create a new admin account
50+
- Re-enter your GitHub and Gitea credentials
51+
- Configure your mirror settings
52+
53+
### What Happens to My Existing Mirrors?
54+
55+
Your existing mirrors in Gitea are **not affected**. The application will:
56+
- Recognize existing repositories when you re-import
57+
- Skip creating duplicates
58+
- Resume normal mirror operations
59+
60+
### Environment Variable Changes
61+
62+
v3.0 uses different environment variables:
63+
64+
| v2.x | v3.0 | Notes |
65+
|------|------|-------|
66+
| `JWT_SECRET` | `BETTER_AUTH_SECRET` | Required for session management |
67+
| - | `ENCRYPTION_SECRET` | New - required for token encryption |
68+
69+
### Need Help?
70+
71+
If you have questions about upgrading:
72+
1. Check the [README](README.md) for v3 setup instructions
73+
2. Review your v2 configuration before upgrading
74+
3. Open an issue if you encounter problems

docker-entrypoint.sh

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -269,82 +269,7 @@ else
269269
bun scripts/manage-db.ts fix
270270
fi
271271

272-
# Run database migrations
273-
echo "Running database migrations..."
274-
275-
# Update mirror_jobs table with new columns for resilience
276-
if [ -f "dist/scripts/update-mirror-jobs-table.js" ]; then
277-
echo "Updating mirror_jobs table..."
278-
bun dist/scripts/update-mirror-jobs-table.js
279-
elif [ -f "scripts/update-mirror-jobs-table.ts" ]; then
280-
echo "Updating mirror_jobs table using TypeScript script..."
281-
bun scripts/update-mirror-jobs-table.ts
282-
else
283-
echo "Warning: Could not find mirror_jobs table update script."
284-
fi
285-
286-
# Run v3 migrations if needed
287-
echo "Checking for v3 migrations..."
288-
289-
# Check if we need to run Better Auth migration (check if accounts table exists)
290-
if ! sqlite3 /app/data/gitea-mirror.db "SELECT name FROM sqlite_master WHERE type='table' AND name='accounts';" | grep -q accounts; then
291-
echo "🔄 v3 Migration: Creating Better Auth tables..."
292-
# Create Better Auth tables
293-
sqlite3 /app/data/gitea-mirror.db <<EOF
294-
CREATE TABLE IF NOT EXISTS accounts (
295-
id TEXT PRIMARY KEY,
296-
userId TEXT NOT NULL,
297-
accountId TEXT NOT NULL,
298-
providerId TEXT NOT NULL,
299-
accessToken TEXT,
300-
refreshToken TEXT,
301-
expiresAt INTEGER,
302-
password TEXT,
303-
createdAt INTEGER NOT NULL,
304-
updatedAt INTEGER NOT NULL,
305-
FOREIGN KEY (userId) REFERENCES users(id)
306-
);
307-
308-
CREATE TABLE IF NOT EXISTS sessions (
309-
id TEXT PRIMARY KEY,
310-
userId TEXT NOT NULL,
311-
token TEXT NOT NULL,
312-
expiresAt INTEGER NOT NULL,
313-
createdAt INTEGER NOT NULL,
314-
updatedAt INTEGER NOT NULL,
315-
FOREIGN KEY (userId) REFERENCES users(id)
316-
);
317-
318-
CREATE TABLE IF NOT EXISTS verification_tokens (
319-
id TEXT PRIMARY KEY,
320-
identifier TEXT NOT NULL,
321-
token TEXT NOT NULL,
322-
expires INTEGER NOT NULL
323-
);
324-
325-
CREATE INDEX IF NOT EXISTS idx_accounts_userId ON accounts(userId);
326-
CREATE INDEX IF NOT EXISTS idx_sessions_token ON sessions(token);
327-
CREATE INDEX IF NOT EXISTS idx_verification_identifier_token ON verification_tokens(identifier, token);
328-
EOF
329-
fi
330-
331-
# Run Better Auth user migration
332-
if [ -f "dist/scripts/migrate-better-auth.js" ]; then
333-
echo "🔄 v3 Migration: Migrating users to Better Auth..."
334-
bun dist/scripts/migrate-better-auth.js
335-
elif [ -f "scripts/migrate-better-auth.ts" ]; then
336-
echo "🔄 v3 Migration: Migrating users to Better Auth..."
337-
bun scripts/migrate-better-auth.ts
338-
fi
339-
340-
# Run token encryption migration
341-
if [ -f "dist/scripts/migrate-tokens-encryption.js" ]; then
342-
echo "🔄 v3 Migration: Encrypting stored tokens..."
343-
bun dist/scripts/migrate-tokens-encryption.js
344-
elif [ -f "scripts/migrate-tokens-encryption.ts" ]; then
345-
echo "🔄 v3 Migration: Encrypting stored tokens..."
346-
bun scripts/migrate-tokens-encryption.ts
347-
fi
272+
echo "Database exists, checking integrity..."
348273
fi
349274

350275
# Extract version from package.json and set as environment variable

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
"db:pull": "bun drizzle-kit pull",
2323
"db:check": "bun drizzle-kit check",
2424
"db:studio": "bun drizzle-kit studio",
25-
"migrate:better-auth": "bun scripts/migrate-to-better-auth.ts",
26-
"migrate:encrypt-tokens": "bun scripts/migrate-tokens-encryption.ts",
2725
"startup-recovery": "bun scripts/startup-recovery.ts",
2826
"startup-recovery-force": "bun scripts/startup-recovery.ts --force",
2927
"test-recovery": "bun scripts/test-recovery.ts",

scripts/migrate-better-auth.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

scripts/migrate-to-better-auth.ts

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)