This utility initializes the tinode database (or upgrades an existing DB from an earlier version) and optionally loads it with data. To force database reset use command line option --reset=true.
-
RethinkDB
go build -tags rethinkdborgo build -i -tags rethinkdbto automatically install missing dependencies. -
MySQL
go build -tags mysqlorgo build -i -tags mysqlto automatically install missing dependencies. -
MongoDB
go build -tags mongodborgo build -i -tags mongodbto automatically install missing dependencies. -
PostgreSQL
go build -tags postgresorgo build -i -tags postgresto automatically install missing dependencies.
Run from the command line.
tinode-db [parameters]
Command line parameters:
--reset: delete the database then re-create it in a blank state; it has no effect if the database does not exist.--upgrade: upgrade database from an earlier version retaining all the data; make sure to backup the DB before upgrading.--no_init: check that database exists but don't create it if missing.--data=FILENAME: filltinodedatabase with data from the provided file. See data.json.--config=FILENAME: load configuration from FILENAME. Example config is included as tinode.conf.--make_root=USER_ID: promote an existing user to root user,USER_IDof the formusrAbCDef123.--add_root=USERNAME[:PASSWORD]: create a new user account and make it root; if password is missing, a strong password will be generated.
Configuration file options:
uid_keyis a base64-encoded 16 byte XTEA encryption key to (weakly) encrypt object IDs so they don't appear sequential. You probably want to use your own key in production.store_config.adapters.mysqlandstore_config.adapters.rethinkdbare database-specific sections:databaseis the name of the database to generate.addressesis RethinkDB/MongoDB's host and port number to connect to. An array of hosts can be provided as well["host1", "host2"].dsnis MySQL's Data Source Name.replica_setis MongoDB's Replicaset name.
The uid_key is only used if the sample data is being loaded. It should match the key of a production server and should be kept private.
The default data.json file creates six users with user names alice, bob, carol, dave, frank, and tino (chat bot user). Passwords are the same as the user names with 123 appended, e.g. user alice gets password alice123; tino gets a randomly generated password. It also creates three group topics, and multiple peer to peer topics. Users are subscribed to topics and to each other. All topics are randomly filled with messages.
Avatar photos curtesy of https://www.pexels.com/ under CC0 license.