Databases
Swisblade provisions managed databases and infrastructure services on demand. Declare what you need in stack.json and the platform handles provisioning, credentials, and connection strings.
Supported infrastructure
| Type | Image | Use case |
|---|---|---|
| PostgreSQL | postgres:16 | Relational database |
| MySQL | mysql:8 | Relational database |
| Redis | redis:7 | Cache and key-value store |
| RabbitMQ | rabbitmq:3 | Message queue |
Declaring dependencies
Add a needs array to any app service:
{
"api": {
"type": "app",
"needs": ["postgres", "redis"]
}
}
On deploy, Swisblade will:
- Create a dedicated database/user/vhost for your project
- Apply resource limits based on your plan tier
- Inject connection strings as environment variables
Connection strings
After deployment, each service that declares needs receives the appropriate environment variable:
PostgreSQL
DATABASE_URL=postgresql://proj_xxx:password@platform-postgres:5432/proj_xxx
Your application can use DATABASE_URL directly with any PostgreSQL client:
// Node.js with pg
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
// Python with psycopg2
conn = psycopg2.connect(os.environ['DATABASE_URL'])
MySQL
DATABASE_URL=mysql://proj_xxx:password@platform-mysql:3306/proj_xxx
Redis
REDIS_URL=redis://proj_xxx:password@platform-redis:6379/0
REDIS_KEY_PREFIX=proj_xxx:
Always prefix your Redis keys with REDIS_KEY_PREFIX. This ensures isolation between projects sharing the same Redis instance.
const prefix = process.env.REDIS_KEY_PREFIX;
await redis.set(`${prefix}my-key`, value);
RabbitMQ
MQ_URL=amqp://proj_xxx:password@platform-rabbitmq:5672/proj_xxx
Each project gets its own RabbitMQ virtual host. Queues and exchanges are isolated by default.
Named databases
In addition to the default database from needs, you can declare extra databases as services with type: "database". Each gets its own user and schema on the shared instance.
{
"services": {
"api": {
"type": "app",
"needs": ["postgres"],
"connects_to": ["analytics-db"]
},
"analytics-db": {
"type": "database",
"engine": "mysql"
}
}
}
The API service receives:
DATABASE_URL— fromneeds: ["postgres"]DATABASE_URL_ANALYTICS_DB— fromconnects_to: ["analytics-db"]
Naming convention
| Resource | Name |
|---|---|
| Database | proj_{slug}_{service_name} |
| User/Role | proj_{slug}_{service_name} |
| Env var | DATABASE_URL_{SERVICE_NAME} |
| Secret key | DB_PASSWORD_{SERVICE_NAME} (postgres) or MYSQL_PASSWORD_{SERVICE_NAME} (mysql) |
Limits
Named databases count toward your plan's database limit alongside default databases from needs. The free tier allows a maximum of 2 databases per stack.
Java applications
Java applications using JDBC need the jdbc: prefix on connection strings. Since Swisblade injects standard URLs (postgresql://..., mysql://...), your Java application should parse the URL and add the prefix. Spring Boot applications can use a custom DataSourceConfig bean to handle this.
External access
PostgreSQL and MySQL
You can connect to your databases from outside the platform using standard clients:
# PostgreSQL
psql "postgresql://proj_xxx:password@swisblade.com:5432/proj_xxx"
# MySQL
mysql -h swisblade.com -P 3306 -u proj_xxx -p proj_xxx
Connection credentials are available in the dashboard under Project → Overview.
Redis and RabbitMQ
These services are internal only and cannot be accessed from outside the platform. They are accessible only by services within your project.
Isolation
Each project gets:
| Resource | Isolation |
|---|---|
| PostgreSQL | Dedicated database and user |
| MySQL | Dedicated database and user |
| Redis | Dedicated ACL user with key prefix restriction |
| RabbitMQ | Dedicated virtual host and user |
Projects cannot access each other's data.
Provisioning and deprovisioning
- Create project: Infrastructure is provisioned automatically on first deploy if
needsis declared. - Add
needs: If you add a new dependency tostack.json, it's provisioned on the next deploy. - Remove
needs: Removing a dependency fromstack.jsondoes not delete the data. Contact support to decommission. - Delete project: All associated databases, users, vhosts, and data are removed permanently.