Database Setup for Self-Hosting
Overview
When you first start your self-hosted DeployStack instance, you'll need to choose and configure a database. This guide will walk you through the process step-by-step.
Important: This setup only needs to be done once when you first install DeployStack.
What You'll Need
- Your DeployStack instance running (backend and frontend)
- Access to your server's environment variables (if choosing cloud databases)
- About 5-10 minutes to complete the setup
Step 1: Access the Setup Page
- Start your DeployStack instance following your installation guide
- Open your web browser and navigate to your DeployStack URL
- You'll be automatically redirected to the setup page at
/setup
If you see a message like "Database setup required" or are redirected to a setup page, you're in the right place!
Step 2: Choose Your Database
You'll see two database options. Here's what each one means:
Option 1: SQLite (Recommended for Most Users)
- Best for: Small to medium teams, development, testing
- Pros:
- No additional setup required
- Works immediately
- No external dependencies
- Perfect for getting started
- Cons:
- Single server only (no clustering)
- Limited to one database file
Choose this if: You're just getting started, have a small team, or want the simplest setup.
Option 2: Turso (For Advanced Users)
- Best for: Advanced users needing distributed databases
- Pros:
- Multi-region replication
- Advanced SQLite features
- Good performance
- Cons:
- Requires Turso account
- More complex setup
Choose this if: You need advanced database features or multi-region deployment.
Step 3: Configure Your Chosen Database
If You Chose SQLite (Easiest)
- Select "SQLite" from the options
- Click "Setup Database"
- Wait for confirmation (usually takes 10-30 seconds)
- Done! You'll be redirected to the main application
No additional configuration needed - SQLite works out of the box!
If You Chose Turso
Before you can use Turso, you need to set up environment variables:
Prerequisites
- Create a Turso account at turso.tech
- Install Turso CLI and create a database:
turso db create deploystack-db
- Get your database URL and auth token:
turso db show deploystack-db turso db tokens create deploystack-db
Server Configuration
Add these environment variables to your server:
TURSO_DATABASE_URL=libsql://your-database-url
TURSO_AUTH_TOKEN=your_auth_token_here
Complete Setup
- Restart your DeployStack instance after setting the environment variables
- Go back to the setup page (
/setup
) - Select "Turso"
- Click "Setup Database"
- Wait for confirmation
Step 4: Verify Setup
After successful setup, you should:
- See a success message confirming database initialization
- Be redirected to the main application
- Be able to create your first user account
If you see any errors, check the troubleshooting section below.
Troubleshooting
"Database setup has already been performed"
- This means your database is already configured
- You can proceed to use the application normally
- If you need to change databases, contact your system administrator
"Configuration incomplete" or "Missing environment variables"
- For Turso: Check that both Turso environment variables are set correctly
- Restart your server after setting environment variables
"Failed to connect" or "Network error"
- Check your internet connection
- For Turso: Verify your database URL and auth token are correct
- Check server logs for more detailed error messages
Setup page keeps loading
- Check that your backend server is running
- Verify the backend is accessible from your browser
- Check browser console for any JavaScript errors
Changing Databases Later
Important: Once you've set up a database, changing to a different type requires:
- Backing up your data (if you have important information)
- Stopping your DeployStack instance
- Removing the database selection file (
persistent_data/db.selection.json
) - Updating environment variables for the new database type
- Restarting and going through setup again
Note: This will reset your application data, so make sure to backup anything important first.
Getting Help
If you're having trouble with database setup:
- Check the server logs for detailed error messages
- Verify environment variables are set correctly
- Ensure your server has internet access (for cloud databases)
- Contact support with your error messages and setup details
Security Notes
- Keep your API tokens secure - never share them publicly
- Use environment variables - don't put credentials directly in code
- Regularly rotate API tokens for cloud databases
- Backup your SQLite database file if using SQLite
Next Steps
After successful database setup:
- Create your administrator account
- Configure your application settings
- Set up user authentication (email, GitHub, etc.)
- Invite your team members
Your DeployStack instance is now ready to use!