Reverse engineer your database and create your ember-data models and ember-cli-mirage factories automatically.
- Change your database structure and regenerate your models to ensure they are always in sync.
- Regenerate safely at any time without loosing your customisations.
- Get up and running quickly and stop wasting time on boilerplate.
- A recent version of JAVA 8 JDK (not JRE) installed on your development system (this is for your development machine only and not required on your hosting server!).
- ember-cli >= 1.13.9 (yet to be released!) but there is a hack for people using older versions
You will get a blueprint error when installing the addon. The fix is to copy and paste the blueprint manually into your project.
Copy the folder yourproject/node_modules/ember-aupac-db-reverse-engineering/blueprints/ember-aupac-db-reverse-engineering/files/db-reverse-engineering
into the root of your project yourproject/db-reverse-engineering
This is for development only - the server hosting your app can run any OS you like.
- Window
- Linux running bash shell
- Mac ??? (needs to be tested)
Note - this will remain beta until 1.0.0, please raise issues if things are not working as expected.
ember install ember-aupac-db-reverse-engineering
- automatic creation of ember-data models.
- automatic creation of ember-cli-mirage factories and routes.
When you install ember-aupac-db-reverse-engineering
a new folder will appear in your applications root directory your-project/db-reverse-engineering
. This folder contains configuration specific to this addon.
You need to download the JDBC driver specific to your database vendor and version. A full list of supported databases can be found here.
Once downloaded, copy the .jar
file to db-reverse-engineering/drvers/
in your project.
- I will accept pull requests to update/add driver links.
Open the file db-reverse-engineering/hibernate.properties
. You need to fill out the fields with the appropriate connection information.
Sometimes the reverse engineering strategy does not interpolate your database the way your would expect/want. For example, you might want single character database fields CHAR(1)
with values of Y/N
interpolated as booleans instead of single character strings in your ember-models.
You are able to fine tune they way it works via the db-reverse-engineering/hibernate.reveng.xml
file.
More information can be found in the hibernate documentation.
- If you find some useful strategies that others might be able to use, submit an issue and we can include it in the documentation somewhere.
The first time you run any of the following commands it will take some time because a number of dependencies need to be downloaded. This only needs to happen once per project and future runs will be much faster.
From within your project run:
ember db-reverse-engineer emberData
your-project/app/models/gen
- contains the generated models. These are replaced every time you run the command and should never be edited manually!your-project/app/models
- contains the ember-data models used in your application. Once created, these are never replaced so feel free to customise them as you wish.
From within your project run:
ember db-reverse-engineer emberCliMirage
your-project/app/mirage/gen
- contains the generated factories and routes.js file. These are replaced every time you run the command and should never be edited manually!your-project/app/mirage/factories
- contains the factories used in your application. Once created, these are never replaced so feel free to customise them as you wish.
The routes are generated in a files called your-project/app/mirage/gen/routes.js
. You can copy/paste these into your your-project/app/mirage/config.js
file but a better way is to import it - that way you get route updates automatically.
//your-project/app/mirage/config.js
import routes from './gen/routes';
export default function() {
//Add this in the existing exported function
routes.apply(this, arguments);
}
You can generate everything using the shorthand syntax.
ember db-rev-eng eD eCM
If the templates we have supplied do not suite your requirements; feel free to change them at your-project/db-referse-engineering/templates
.
The templating language is called freemarker.
-
Should the db-reverse-engineering folder be included in version control? ANSWER: Yes - except for the
tmp/
and.gradle
folders. For git users there is already a.gitignore
file excluding these folders. -
I am behind a proxy and get errors when downloading dependencies! ANSWER: See
db-reverse-engineering/gradle.properties
git clone
this repositorynpm install
bower install
ember server
- Visit your app at http://localhost:4200.
ember test
ember test --server
ember build
For more information on using ember-cli, visit http://www.ember-cli.com/.