Getting started with TogetherDB

Use TogetherDB as to let others see and work on your database. To get started you need to have an existing MySQL or PostgreSQL database. That can be a cloud database from Google or AWS, can be hosted by a SaaS like ElephantSql or self-hosted on your own server or virtual machine. Only local databases on your own computer are not supported yet.

Signin on tgdb

If you haven't already, create an account by signing in with your Google account!

Get connection details to your database

You need to provide connection details to your database so that the system can access it. You need to provide hostname, database, username and password.

If you want to keep it simple, just provide access for the super user that has all permissions in the database. In that case you can skip to the next section.

If you want better security and control you can create a new role in your database with the appropiate permissions. Following the scripts below creates a role togetherdb that has permisssions to read and write all data in the databases you select but can not change the table structure, can not drop the database or tables, can not create new roles etc. This is the recommended way of giving TogetherDB access to your database.

Create user in PostgreSQL

  1. Create a new user for TogetherDB. Login to your database and issue the following statements:
CREATE ROLE togetherdb WITH LOGIN PASSWORD 'secret123';

Now for all databases that you want to manage from TogetherDB, connect to that database and execute:

GRANT CONNECT ON DATABASE <dbname> TO togetherdb;

GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON ALL TABLES IN SCHEMA public TO togetherdb;
GRANT SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO togetherdb;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO togetherdb;

ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON TABLES TO togetherdb;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, UPDATE ON SEQUENCES TO togetherdb;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT EXECUTE ON FUNCTIONS TO togetherdb;

-- TODO: Test

Create user in MySQL

-- TODO: Determine from https://dev.mysql.com/doc/refman/8.0/en/grant.html#grant-table-privileges
-- TODO: Test

-- grant select, insert, update, delete on ru_users* to. 'togetherdb'@'35.157.231.179';
-- create user 'togetherdb'@'35.157.231.179' identified by 'secret';

Create connection

In your dashboard, choose new connection and follow the dialog. After entering the host name we will determine the worker instance closest to your database and show you its IP address. You will need to open your database for that ip address.

For Google Cloud

In the console select your database, go to Connections and in Connectivity, Public IP add the IP address that is shown in step 3 of the TogetherDB dialog.

For Amazon AWS

Go here and create a new security group with group name TogetherDB, description Access for collaboration on TogetherDB.com, leave VPC as it is and add an outbound rule type Custom TCP, Port range 5432, Destination Custom and the IP address you got in the TogetherDB dialog, followed by /32, so for example "58.10.209.54/32". See here.

Then here select your database and in Connectivity & security switch Public accessibility to yes and ensure that security group is selected.

For self-hosted

TODO

Invite others to your database

After you created your connection it should show the available databases on that system. Click on the one that you want to collaborate on and choose the "add person" icon on the top right. Enter the email address and whether that person should have read or write access.

The invited person will receive an email about the invitation and after creating their account they will be able to access the database from their dashboard. If you want to retract the invitation or change the permission, go to the database again and click on the invited's person's avatar on the top right.

Help

If some step of the setup didn't work or you need more information, please contact us at hello@togetherdb.com. We are always happy to help or just chat! Also we just started out so please be forgiving if there are still one or two bugs! 🙏