Skip to main content

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

TypeImageUse case
PostgreSQLpostgres:16Relational database
MySQLmysql:8Relational database
Redisredis:7Cache and key-value store
RabbitMQrabbitmq:3Message queue

Declaring dependencies

Add a needs array to any app service:

{
"api": {
"type": "app",
"needs": ["postgres", "redis"]
}
}

On deploy, Swisblade will:

  1. Create a dedicated database/user/vhost for your project
  2. Apply resource limits based on your plan tier
  3. 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:
important

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 — from needs: ["postgres"]
  • DATABASE_URL_ANALYTICS_DB — from connects_to: ["analytics-db"]

Naming convention

ResourceName
Databaseproj_{slug}_{service_name}
User/Roleproj_{slug}_{service_name}
Env varDATABASE_URL_{SERVICE_NAME}
Secret keyDB_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:

ResourceIsolation
PostgreSQLDedicated database and user
MySQLDedicated database and user
RedisDedicated ACL user with key prefix restriction
RabbitMQDedicated virtual host and user

Projects cannot access each other's data.

Provisioning and deprovisioning

  • Create project: Infrastructure is provisioned automatically on first deploy if needs is declared.
  • Add needs: If you add a new dependency to stack.json, it's provisioned on the next deploy.
  • Remove needs: Removing a dependency from stack.json does not delete the data. Contact support to decommission.
  • Delete project: All associated databases, users, vhosts, and data are removed permanently.