#### --------------------------------------------------------------------------------- ####
#### set environment                                                                   ####
#### --------------------------------------------------------------------------------- ####
--
Edit file niota_setenv.bat to set your current values for environment variables mentioned below.
--
nMySQLHome must be set to your \bin folder of the MySQL tools you need to use.

Connection targets and databases are defined in conf\tools\hosts.conf and conf\tools\databases.conf
using the unified semicolon syntax:
  hosts.conf:       id;description;host;port
  databases.conf:   database_name;description;type   (type = meta or system)

The unified HTA ui\NiotaDatabaseOutpost.hta is the recommended entry point for all database
operations (setup, backup, restore, populate, configure). It shows populate and application
features based on the selected database type. Legacy HTAs (DatabaseOutpost, MetaDatabaseOutpost,
SystemDatabaseOutpost) remain available during transition.

nMySQLServer, nMySQLPort, and nMySQLAdmin are no longer set in niota_setenv.bat.
They are passed per run via the HTA connection settings or CLI arguments (see examples below).

-- please check your settings there
MySQL\bin folder (nMySQLHome in niota_setenv.bat)
Connection targets (conf\tools\hosts.conf)
Databases (conf\tools\databases.conf)
--

#### --------------------------------------------------------------------------------- ####
#### CLI argument format (all do_*.bat scripts)                                        ####
#### --------------------------------------------------------------------------------- ####
--
do_xxx.bat <host> <port> <username> <database> <password> <option> [param4]

Examples:
  do_setup_metadb.bat localhost 3369 root niota_meta mypw schemas
  do_backup_metadb.bat localhost 3369 root niota_meta mypw backup allobjects
  do_restore_metadb.bat localhost 3369 root niota_meta mypw restore dump.sql
--

#### --------------------------------------------------------------------------------- ####
#### create schemas                                                                    ####
#### --------------------------------------------------------------------------------- ####
--
Once your environment settings are done correctly you can run the scripts to build up your metadatabase and populate it with content.

run script "do_setup_metadb" with option "schemas"
This script create your
- meta database 
- deploy database
- warp (core) database
--
note that you have to connect to an exististing schema to create a new schema.
eg.
...\bin>do_setup_metadb localhost 3369 root sys mypw schemas

#### --------------------------------------------------------------------------------- ####
#### to have a client or not to have a client                                          ####
#### --------------------------------------------------------------------------------- ####
You can run niota from system meta db "niota_meta" or you can define an one meta database for your local clients.
We strongly recommend to do this.

Set up has then later done for both - the system client in niota_meta and for every own client meta database.

#### --------------------------------------------------------------------------------- ####
#### set up a meta database for a logical local "client"                               ####
#### --------------------------------------------------------------------------------- ####
Set desired metadatbase suffix for your local client.
Default name is "niota_meta_c100" -- you can change the suffix to your needs e.g. niota_meta_IBM
Suffix should match the 5 characters client ID
Set your desired client meta database name in 
..\tools\database\object\clients\client_schemas.sql and run script below
and run the script 
eg.
...\bin>do_setup_metadb localhost 3369 root sys mypw clients

or
execute ddl directly in your workbench
CREATE DATABASE if not exists niota_meta_<myID> CHARACTER SET UTF8MB4  COLLATE UTF8MB4_general_ci; 

please double check if your database exists now on the disired server.

#### --------------------------------------------------------------------------------- ####
#### create database object in meta data database(s)                                   ####
#### --------------------------------------------------------------------------------- ####

Now Create tables, .....
You can run every part of the setup process separately by setting the proper option or 
run all at once with option "allobjects"

this runs create of 
tables, functions, views, ... 
in database niota_meta

...\bin>do_setup_metadb localhost 3369 root niota_meta ***** allobjects

#### --------------------------------------------------------------------------------- ####
#### populate the meta database(s)                                                     ####
#### --------------------------------------------------------------------------------- ####

Now insert values for configuration and formats into the previously created tables.

 run do_populate_metadb.bat <host> <port> <username> <database> <password> <option>

...\bin>do_populate_metadb localhost 3369 root niota_meta ***** config

You can run every part of the setup process separately by setting the proper option or 
run all at once with option "allcontent"
When you run it separately these options are valid:
config
format

#### --------------------------------------------------------------------------------- ####
#### create database users(s)                                                          ####
#### --------------------------------------------------------------------------------- ####
-
We strongle recommend to create dedicated database users to access your meta db via niota web
DO NOT USER root or admin users.

Configure provided scripts in folder user and run the scripts to create users and grant minimimum privileges required.



#### --------------------------------------------------------------------------------- ####
#### install the applications                                                          ####
#### --------------------------------------------------------------------------------- ####
Now you have to install at least one application to be able to configure niota locally.
The most basic tool for this is "adminpages". 
Advanced features are contained in application "spock".

To install an applicatin into you local meta database you have to run

 do_configure_application.bat <host> <port> <username> <database> <password> <option>

...\bin>do_configure_application localhost 3369 root niota_meta *** adminpages
 
 
 do_configure_application.bat localhost 3369 root niota_meta mypw spock
 
