Deploy data
The typical Snaplet workflow involves restoring snapshots to your local development PostgreSQL database to code against. While working locally with snapshots allows for more flexibility, configurability, and the ability to work offline without network latency or connectivity interruptions, there are situations where being able to preview your snapshot on an instant serverless database, called preview databases, is useful.
For example, if you're currently in the process of evaluating Snaplet, being able to restore a snapshot to a preview database allows you to view that database without needing to download and install the Snaplet CLI. Preview databases are also easy to share with team members, and allow you to have isolated preview databases for preview deployments.
As such, Snaplet supports the creation of instant preview databases from snapshots, which allows users to view, code against, or run pull-request previews against a preview serverless PostgreSQL database.
These preview databases can be created from within the Snaplet Cloud dashboard, or the Snaplet CLI. Note, Snaplet can only create a preview database from an unencrypted snapshot.
Each Snaplet Project receives a PostgreSQL server instance where multiple preview databases can be created.
Preview databases on Snaplet Cloud
To create a preview database from within Snaplet Cloud, you'll need to have captured a snapshot from your source database - refer to the Getting Started guide if you need help. From the Snaplet dashboard, click on your snapshot, and then select the 'Previews' tab. From here, simply click the 'Create new preview database' button.
The first preview database may take a moment to create, depending on the size of your snapshot. Once done, you'll be able to copy the connection string for the database to import into your preferred database client.
Preview databases using Snaplet CLI
create [snapshot]
The create subcommand generates a new preview database using a specified snapshot:
url [name]
This command retrieves the connection URL for a specified preview database. The name parameter is optional and if not provided, the most recent preview database will be used.
list [snapshot]
The list subcommand shows all preview databases created from a specific snapshot:
reset [name]
This command reset the state of a specified preview database. The name parameter is required and specifies the name of the preview database to reset.
drop [name]
This command drops a specified preview database. The name parameter is required and specifies the name of the preview database to drop.