This module extracts the structure of a database, transforms it into JHipster entities and their dbh counterparts and produces JSON files with it.
These files are meant to be used with JHipster and / or db-helper.
Note: This module is a prototype, it doesn't do much at the moment. However it is easy to contribute to the project, just keep reading this document.
At the moment, this module :
- supports mysql
- can extract the table structure and let you select which table you want
It doesn't integrate with JHipster or DB-Helper yet, so you must use it as a standalone module :
yarn add node-db-importer
And you can use it as any other module or run it alone :
$ node node_module/node-db-importer/index
- The database you want to import must be running :
- mysql : You need reading access to
information_schema
table
- mysql : You need reading access to
- Node latest stable release (v6.8 at least). Upgrade Node if necessary.
The module will ask you needed information and output the files into two directories : .jhipster
and .dbh
.
You may answer to the module prompts or provide a configuration file named .db-config.json. The configuration file must have the following format :
{
"dbms": "mysql",
"host": "10.10.10.10",
"user": "root",
"port": "3306",
"password": "password",
"schema": "databaseIWantToImport"
}
All fields from the configuration file will be ran against validation, a warning will be printed if it doesn't pass and you'll be offered to give a new value.
No particular precaution has been taken concerning the password, store it at your own risk.
It will classify found tables into four categories :
- tables : any table which doesn't fit the following categories, checked by default
- twoTypeJunction : tables used as a junction table between two other tables, you most probably want to let the module to create a many-to-many relationship with it.
- jhipster: jhipster own tables, depending the customisation of your project you want them or not.
- liquibase: liquibase tables, you most probably don't want anything to do with it.
The tables you check will be used to create entities and won't be available to create many-to-many relationships.
Check our doc for more info.
Workflow: Your contributions are welcome. Create a Github issue to discuss enhancements, new features, etc. Please make pull requests to the dev
branch.
Testing: All tests must pass. We use Mocha and Istanbul (nyc) for unit testing, and Travis for integration testing.
$ npm test
Linting: Linting enforces code conventions. We use eslint with the AirBnB ruleset extended with custom rules. Travis tests linting and will fail the build with there is any linting error (warning are accepted).
You are welcome to discuss the module in db-helper's gitter.requiredrequiredrequired
For private messages : bmichaux@altissia.com