# README
Developing
Prerequisites
- Golang development environment
- Postgres 10 server
For data model changes you'll need:
- golang-migrate cli tool installed and in your path
- sqlboiler installed
Also recommended is fresh for automatic recompiling.
Downloading
Data Model
Domains
- all domains have a base TLD which is the name (i.e.
sektorseven.net
) - domains can have one or more user accounts associated, with permissions
- by default, if a user account is associated with a domain, it can see all the information
- admin permission allows users to be added to the domain
- email permission allows the modification of email users and forwards
Config file setup
- Copy
sqlboiler.sample.toml.sample
andconfig.sample.json
to new files - removing the.sample
- You'll need to at least change the Database Name (
<DATABASE>
), DB User (<DBUSER>
) and DB Password (<DBPASS>
) in those files to a suitable config for your system.- It's a good idea to use a unique database and user and a random password to avoid issues with your dev environment
- You may need to change the host and port entries to reflect your local setup. The example fields in
config.sample.json
are the defaults. config.sample.json
is used by the live application, whilesqlboiler.sample.toml
is only used to generate new datamodels from database data.- the root "development" flag is only used to perform migrations from files.
Helper tool
In the subdirectory helperTool
of this repo is package that compiles a helper tool.
This should be built via go build
and the executable moved into your path.
- By default the helper tool will look for your config file in the working directory
- By default the helper tool will use the postgres user
postgres
(this needs to be a root user) - By default the helper tool will use the postgres password
rootpassword
- If you've changed the docker config these may need to be specified - run the tool with the
/h
option to get help
The following sections will make use of the helper tool to create databases and users.
Database Setup
- Setup the config file with the correct:
- database host
- database port
- the desired database name to use (this will be created and if this exists, it will be overwritten)
- the desired user to user (this will be created and if this exists, it will be overwritten)
- the desired user's password
- run the helper tool with the
createDB
command - if no errors are encountered, the base setup is complete!
Creating a user
- You'll need to have completed the database setup step above.
- You'll need to have run the server at least once to have crated the required tables
- run the helper tool with the
createUser
command. This command takes the following parameters:username
- the desired username for the new userpassword
- the password for the new useremail
- the email for the new user- (optional)
superadmin
- if the user is a super/root administrator. defaults to false
- if no errors are encountered, the user was created!
Changing data models
- Ensure you have the development flag turned on to test your migration scripts
- run the helper tool with the
createMigration
command. This command takes the following parameters:directory
- the root directory of this repository (if the helpertool is being run in the helperTool directory, then this will be either..\
or../
depending on your os)name
- the name of the migration to create. Should be related to what the migration does, should probably be enclosed in quotes. The tool will replace whitespace with_
, and non-alpha numeric characters with-
- Specify the migration syntax in the new files created in the
datasource/migrations/
directory - Test your migration via either:
- compiling and running the server with the development flag turned on
- manually running the migration via
migrate -source file://datasource/migrations -database postgres://<DBUSER>:<DBPASS>@localhost:15432/<DBNAME>?sslmode=disable up
- Once your migration has the correct SQL, regenerate the bindata using the helperTool's
updateBindata
commanddirectory
- the root directory of this repository (if the helpertool is being run in the helperTool directory, then this will be either..\
or../
depending on your os)
- Then generate the models:
- Ensure you have copied
sqlboiler.sample.toml
tosqlboler.toml
and changed the various directives to your local ones. - Run
sqlboiler psql -o datamodels_raw -p datamodels_raw -c sqlboiler.toml
from the root of the repo.
- Ensure you have copied
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author