Skip to main content

Branch

Symbol for Branch

Definition#

The first time a data-container is created from a data-image, a new timeline is created by default.

You can think of the default timeline as the default Git branch (main).

Changes made to your database (data-container) can be recorded along this timeline as revisions.

When you load a previous revision, a new timeline is created.

You can think of this as a new branch.

Example#

In this example we create a new data-container and make 3 revisions to it.

$ spawnctl create data-image -f ./development.yaml
Data image 'dev' (10001) created!
$ spawnctl get data-images
NAME IMAGE ID ENGINE STATUS MESSAGE CREATED
dev 10001 PostgreSQL 2 Created 2 minutes ago
$ spawnctl create data-container --image dev
Data container 'dev-rambbomj' (10001) created!
-> Host=instances.spawn.cc;Port=53223;User ID=<some_user_id>;Password=<some_password>;
$ spawnctl get data-containers
NAME CONTAINER ID REVISION STATUS MESSAGE ENGINE CREATED
dev-rambbomj 10001 rev.0 2 Running PostgreSQL 1 minute ago

Notice the created data container has revision rev.0.

You can now make changes to that container by executing any SQL you like.

In this example we connect to the PostgreSQL data container (database) using psql.

$ psql -h instances.spawn.cc -p 53223 -U <some_user_id>
Password for user <some_user_id>:
psql (10.5, server 11.0 (Debian 11.0-1.pgdg90+2))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
<some_user_id>=# CREATE TABLE customers(id INT);
CREATE TABLE
<some_user_id>=# \dt
List of relations
Schema | Name | Type | Owner
--------+-----------+-------+------------------
public | customers | table | <some_user_id>
(1 row)

We can now perform a save operation on this data container.

$ spawnctl save data-container dev
Saving container....
Data container 'dev-rambbomj' saved!
New revision is 'rev.1'

Notice the data container has now revision rev.1.

$ spawnctl get data-containers
NAME CONTAINER ID REVISION STATUS MESSAGE ENGINE CREATED
dev-rambbomj 10001 rev.1 2 Running PostgreSQL 1 minute ago

If you perform more save operations, revisions will be created as you do so.

After 3 save operations, this branch now contains rev1, rev2 and rev3.

You can now load any revision you like

In our case we load rev1. A new branch is created.

$ spawnctl load data-container dev-rambbomj --revision=rev.1
Data container 'dev-rambbomj' loaded!
New revision is 'rev.1-ciys.0'

If we connect to that new container and made more saves, your new branch would now have rev1.xxxx.1, rev1.xxxx.2, and rev1.xxxx.3

rev1xxxx3
name of the data containerbranch identifierrevision number on this branch