NetherDB Command Line
netherdb config-new <filename> --force
netherdb config-new conf/env/dev/netherdb.json
This will make a new JSON file at the specified location that can then be filled in with the relevant config settings.
netherdb sql-create $Class [--db=$Alias] [--conf=$PathToJSON]
netherdb sql-create Namespace.ClassName --conf=conf/env/dev/netherdb.json
Given a class name it will be autoloaded and all the relevant attributes will be read to generate the SQL that describes this table. If the database config was supplied it will then ask you if you'd like to execute it upon that server.
Namespace path to the class may be written normally but shell escaped (so \\
likely) but also with .
or -
as namespace separators instead just to make it easier to deal with CLI things.
If --conf
option is supplied it will automatically attempt to connect to the Default
database and offer you the opportunity to immediately execute the
SQL on that server. You can specify which of the databases in the config file with the --db
option.
$ netherdb sql-create Local\\Test\\User
-- SQL BEGIN
CREATE TABLE `Users` (
`ID` BIGINT UNSIGNED AUTO_INCREMENT,
`Name` VARCHAR(32),
PRIMARY KEY (`ID`) USING BTREE
)
CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci
ENGINE=InnoDB
-- SQL END
With a DB connection:
$ netherdb sql-create Local.Test.Entity --db=Default --conf=conf/env/dev/netherdb.json
Connecting to Default...
-- SQL BEGIN
CREATE TABLE `TestEntity` (
`ID` BIGINT UNSIGNED AUTO_INCREMENT,
`Name` VARCHAR(32),
PRIMARY KEY (`ID`) USING BTREE
)
CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci
ENGINE=InnoDB
-- SQL END
Execute on Default?
(y/n): y
> OK
If there are any errors when executing the query they will be presented.
Execute on Default?
(y/n): y
> Table 'TestEntity' already exists
ERROR: query failed