National Pizza Magistrate

    ember-aupac-db-reverse-engineering

    0.9.2 • Public • Published

    ember-aupac-db-reverse-engineering

    NPM package Ember Observer Score

    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.

    Requirements

    • A recent version of JAVA JDK installed on your development system (this is for development purposes 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

    Using a version of ember-cli < 1.13.9

    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

    Operating Systems Supported

    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)

    Installing

    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

    Features

    • automatic creation of ember-data models.
    • automatic creation of ember-cli-mirage factories and routes.

    Setup

    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.

    Step 1 - Get your JDBC Driver

    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.

    Step 2 - Setup your database connection

    Open the file db-reverse-engineering/hibernate.properties. You need to fill out the fields with the appropriate connection information.

    Step 3 - Define Custom Mappings (Not Required)

    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.

    Commands

    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.

    Generate ember-data models

    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.

    Generate ember-cli-mirage factories & routes

    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);
    }

    Shorthand

    You can generate everything using the shorthand syntax.

    ember db-rev-eng eD eCM

    Customising the Templates

    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.

    Questions

    • 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.

    • Gradle can't download behind a proxy! ANSWER: Create a files called gradle.properties inside the db-reverse-engineering folder and add the following lines updating the configuration as appropriate.

      systemProp.http.nonProxyHosts=PROXY_IP
      systemProp.http.proxyHost=PROXY_IP
      systemProp.http.proxyPort=PROXY_PORT
      systemProp.https.nonProxyHosts=PROXY_IP
      systemProp.https.proxyHost=PROXY_IP
      systemProp.https.proxyPort=PROXY_PORT
    

    Contributing

    Installation

    • git clone this repository
    • npm install
    • bower install

    Running

    Running Tests

    • ember test
    • ember test --server

    Building

    • ember build

    For more information on using ember-cli, visit http://www.ember-cli.com/.

    Install

    npm i ember-aupac-db-reverse-engineering

    DownloadsWeekly Downloads

    1

    Version

    0.9.2

    License

    MIT

    Last publish

    Collaborators

    • aupac