Code Monkey home page Code Monkey logo

sequelize-auto's Introduction

Sequelize logo

npm version npm downloads contributors Open Collective sponsor Merged PRs semantic-release License: MIT

Sequelize is an easy-to-use and promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite, DB2, Microsoft SQL Server, Snowflake, Oracle DB and Db2 for IBM i. It features solid transaction support, relations, eager and lazy loading, read replication and more.

Would you like to contribute? Read our contribution guidelines to know more. There are many ways to help! πŸ˜ƒ

πŸ’» Getting Started

Ready to start using Sequelize? Head to sequelize.org to begin!

πŸ’Έ Supporting the project

Do you like Sequelize and would like to give back to the engineering team behind it?

We have recently created an OpenCollective based money pool which is shared amongst all core maintainers based on their contributions. Every support is wholeheartedly welcome. ❀️

πŸ“ Major version changelog

Please find upgrade information to major versions here:

πŸ“– Resources

πŸ”§ Tools

πŸ’¬ Translations

⚠️ Responsible disclosure

If you have security issues to report, please refer to our Responsible Disclosure Policy for more details.

sequelize-auto's People

Contributors

cedrouck avatar dbpolito avatar demus avatar dpomerantz-jci avatar durango avatar erickfmm avatar greenkeeper[bot] avatar gsdnano avatar honzajerabek avatar ihorskyi avatar isac322 avatar jaredbrookswhite avatar jiaxingzheng avatar joaoe avatar jonathanwolfe avatar karpikpl avatar locene avatar mat813 avatar radiergummi avatar rainabba avatar ray0427 avatar retfah avatar sdepold avatar simov avatar sjfkai avatar sseewald avatar steveschmitt avatar strumwolf avatar zhfish avatar zypa13510 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sequelize-auto's Issues

Associations of Model

Does it generate associations of all foreign / primary keys as well from the tables definition?

cannot connect with user credentials

just used this components with the credentials i use normally, but returns an error

sequelize-auto -h 127.0.0.1 -d fettle -u root -x 1324 -e mysql -o "./modelss"

{ [SequelizeAccessDeniedError: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)]
  name: 'SequelizeAccessDeniedError',
  message: 'ER_ACCESS_DENIED_ERROR: Access denied for user \'root\'@\'localhost\' (using password: YES)',
  parent:
   { [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)]
     code: 'ER_ACCESS_DENIED_ERROR',
     errno: 1045,
     sqlState: '28000',
     fatal: true },
  original:
   { [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)]
     code: 'ER_ACCESS_DENIED_ERROR',
     errno: 1045,
     sqlState: '28000',
     fatal: true } }

UUID primary key for MSSQL

After importing some MS SQL (2008R2) table i have following field definition in my model:

ID: {
     type: 'UNIQUEIDENTIFIER',
     allowNull: false,
     defaultValue: '(newid())',
     primaryKey: true
 }, 

Actually, IMHO, it should be like this:

ID: {
     type: DataTypes.UUIDV4,
     allowNull: false,
     primaryKey: true
 }, 

P.S. .UUIDV4 makes this field as uuid-type and auto-generate new value for it

Error: The dialect mssql is not supported.

When I run the following command

sequelize-auto -h [server] -d [db name] -u [username] -x [pwd]   -e mssql -o './models'

I get the following error:
/Users/this-guy/.nvm/versions/io.js/v2.0.1/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/sequelize.js:125
throw new Error("The dialect " + this.getDialect() + " is not supported.
^
Error: The dialect mssql is not supported.

I'm trying to connect to a azure db if that makes a difference.

Auto generate models from views

It would be really nice if views would also generate models
In my case a postgresql materialized view.
Or did I miss how to do that?

Reference different schemas under the same database?

How can I build models from different schemas inside the same database?

I have a database called 'transform' and under that database I have a schema called 'public' and another called 'schema2'. This module seems to select which ever is designated as the default schema, which is 'public' in my case. How can select 'schema2'?

id autoIncrement is not set while generating models from mysql db

I have a mysql db, and generate the models like so:

$ sequelize-auto -o "./models" -d MY_DATABASE -h localhost -u USERNAME -p 3306 -x USERPASSWORD -e mysql

For the id table fields, which are set to AUTOINCREMENT in the mysql database, the sequelize-auto does not provide the autoincrement descriptor, and subsequently the insert operation generates SequelizeValidationError.

If I add autoincrement by hand, however, like so:

id: {
      type: DataTypes.INTEGER(10),
      allowNull: false,
      primaryKey: true,
      autoIncrement: true
    },

Everything works.

Allow customizable model template instead of hardcoded one

Customizable template (EJS/Nunjucks) instead of hardcoded one would be great.

I've recently run across the issue that sequelize-auto defines the models with sequelize.define. This essentially makes the models non-extendable, while extending auto-generated ORM models is something that goes without saying.

This could solve several other issues, for example #19.

mssql -Unhandled rejection TypeError: undefined is not a function at Object.module.exports.removeTicks

β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
β”œβ”€β”€ [email protected]
└── [email protected]

I am hitting this issue with the environment above when tried to retrieve mssql model

Executing (default): SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES;
Unhandled rejection TypeError: undefined is not a function
at Object.module.exports.removeTicks (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/utils.js:376:14)
at Object.module.exports.addTicks (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/utils.js:372:29)
at Object.exports.mssql.getForeignKeysQuery (/usr/local/lib/node_modules/sequelize-auto/lib/dialects/index.js:155:54)
at mapForeignKeys (/usr/local/lib/node_modules/sequelize-auto/lib/index.js:44:23)
at /usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:181:20
at Object.async.forEachOf.async.eachOf (/usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:233:13)
at Object.async.forEach.async.each (/usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:209:22)
at /usr/local/lib/node_modules/sequelize-auto/lib/index.js:38:11
at tryCatcher (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/bluebird/js/release/util.js:11:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:491:31)
at Promise._settlePromise (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:548:18)
at Promise._settlePromise0 (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:593:10)
at Promise._settlePromises (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:676:18)
at Async._drainQueue (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/bluebird/js/release/async.js:125:16)
at Async._drainQueues (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/bluebird/js/release/async.js:135:10)
at Immediate.Async.drainQueues as _onImmediate

Anyone having similar issue?

PK with autoincrement is set to false in "allowNull"

Sequelize doesn't let me create new records without setting the id in this case, which is an PK and autoIncrement column in database, this is by logic setting null to false, so sequelize must detect if autoIncrement is set so it could ignore this whenever i create a new record

References for id generated with nulled model & key if key is VARCHAR (PostgreSQL)

PostgreSQL: 9.2
sequelize-auto: 0.2.7

SQL to reproduce:

CREATE TABLE article
(
    id          VARCHAR(32)       NOT NULL, -- <-- IF id is SERIAL then everything is fine here
    content     TEXT              NOT NULL,

    CONSTRAINT  article_pk        PRIMARY KEY (id)
);

CREATE TABLE main
(
    id          SERIAL            NOT NULL,
    article_id  VARCHAR(32)       NOT NULL,

    CONSTRAINT  main_pk           PRIMARY KEY (id),
    CONSTRAINT  main_article_fk   FOREIGN KEY (article_id)  REFERENCES article (id)
);

RESULT:

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('article', {
    id: {
      type: DataTypes.STRING,
      allowNull: false,
      primaryKey: true,
      references: {
        model: 'null',   // WUT?
        key: 'null'      // 4kWUT?
      }
    },
    content: {
      type: DataTypes.TEXT,
      allowNull: false
    }
  }, {
    tableName: 'article',
    freezeTableName: true
  });
};

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('main', {
    id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      autoIncrement: true
    },
    article_id: {
      type: DataTypes.STRING,
      allowNull: false,
      primaryKey: true,
      references: {
        model: 'article',
        key: 'id'
      }
    }
  }, {
    tableName: 'main',
    freezeTableName: true
  });
};

Mention something about installing the dialect module globally in the docs ?

I tried using the tool as explained in the README file.

I installed the sequelize-auto module globally and then kept hitting:

You need to install mysql package manually

/home/cristi/.nvm/v0.10.33/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:306
    var connection = mysql.createConnection(connectionConfig);
                           ^
TypeError: Cannot call method 'createConnection' of undefined
    at module.exports.connect (/home/cristi/.nvm/v0.10.33/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:306:28)
    at Object.pool.Pooling.Pool.create (/home/cristi/.nvm/v0.10.33/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:131:19)
    at createResource (/home/cristi/.nvm/v0.10.33/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:258:13)
    at dispense (/home/cristi/.nvm/v0.10.33/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:250:9)
    at Object.me.acquire (/home/cristi/.nvm/v0.10.33/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:316:5)
    at null.fct (/home/cristi/.nvm/v0.10.33/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:241:19)
    at null.<anonymous> (/home/cristi/.nvm/v0.10.33/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/emitters/custom-event-emitter.js:24:18)
    at processImmediate [as _immediateCallback] (timers.js:345:15)

The issue was that I did not have mysql installed globally (npm install -g mysql). Maybe you could update the README file with a small note on this? Otherwise, at least someone having the same issue might have the fix here.

Not much of a big deal, so feel free to ignore.

primary composite keys with foreign keys

using mysql.
3 composite key fields
2 of those fields have foreign keys.

the primaryKey attribute is not generated.
Traced the issue to this commit: 54d3753

removing the change fixed my issue, but I'm sure the commit was needed, -- how can I help?

Does -c option works well

Hello guys,

I'm just curious how can I set default options for every model object e.g.

{
"timestamps" : false,
"freezeTableName": true
}

I tried this as config file, but it doesn't include this information in model files

Thanks in advance

error _.contains is not a function in Postgres

Hello I have Postgres db.
When I write command
sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres
with my params I have this error in console:

Unhandled rejection TypeError: _.contains is not a function
    at Object.exports.postgres.isSerialKey (/usr/local/lib/node_modules/sequelize-auto/lib/dialects/index.js:130:14)
    at /usr/local/lib/node_modules/sequelize-auto/lib/index.js:124:110
    at arrayEach (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/lodash/lodash.js:473:11)
    at Function.forEach (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/lodash/lodash.js:7607:11)
    at /usr/local/lib/node_modules/sequelize-auto/lib/index.js:123:11
    at arrayEach (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/lodash/lodash.js:473:11)
    at Function.forEach (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/lodash/lodash.js:7607:11)
    at /usr/local/lib/node_modules/sequelize-auto/lib/index.js:103:9
    at /usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:181:20
    at Object.async.forEachOf.async.eachOf (/usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:233:13)
    at Object.async.forEach.async.each (/usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:209:22)
    at generateText (/usr/local/lib/node_modules/sequelize-auto/lib/index.js:91:11)
    at /usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:52:16
    at done (/usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:246:17)
    at /usr/local/lib/node_modules/sequelize-auto/node_modules/async/lib/async.js:44:16
    at /usr/local/lib/node_modules/sequelize-auto/lib/index.js:83:7

"," present when allowNull is the last option

When i generate my models and that allowNull is the last option, there is a "," before the end of the JSON :

    cmd_value: {
  type: 'DOUBLE(14,4)',
  allowNull: false,
  defaultValue: '0.0000' //options generated perfectly
},
cmd_id: {
  type: DataTypes.BIGINT,
  allowNull: false, // , has nothing to do here ...
}

Thanks for this answone lib !

Feature: autoloading the database credentials

I think it would be a neat idea to keep below command line even simpler, by autoloading the database configuration, but still being able to enter the credentials manually if you want to:

sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres

I mean like doctrine:

php vendor/bin/doctrine orm:schema-tool:create

As you can see you don't have to enter the database credentials, cause they're already specified inside the project. Doctrine uses the config/cli-config.php file for this:

<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;

// replace with file to your own project bootstrap
require_once 'app/bootstrap.php';

return ConsoleRunner::createHelperSet($entityManager);
?>

The above $entityManager contains the database connection singleton.

Maybe an idea for the sequelize-auto? So it uses the credentials of the current environment by default. Well actually above samples of Doctrine are for creating tables from your models, and not the opposite, but I just want to clarify my idea of autoloading the database configuration.

Documentation needs a better tutorial for newbies

Hi, I am new to sequelize and sequelize-auto and I was wondering if some questions could be answered and put in the readme.

I used the programmatic API in order to call sequelize-auto and it generates the models properly.
I was wondering since sequelize-auto requires sequelize and uses the connection info in order to generate the models, is there an instance of sequelize somewhere inside my new SequelizeAuto() once run has been called? If so, where is it? And did it import the models?

In the programmatic API section of the README, I've modified like so:

var SequelizeAuto = require('sequelize-auto')
var auto = new SequelizeAuto('database', 'user', 'pass');

auto.run(function (err) {
if (err) throw err;

console.log(auto.tables); // table list
console.log(auto.foreignKeys); // foreign key list

// Sequelize API call...
auto.tables["User"].findAll({attributes: ["id", "name"]});
};

Which is not working since tables is only an array describing the model.
Do I need to import the models manually using sequelize?

table names need adding to models

The models generated ok but half the table names were wrong as sequelize-restful does some weird pluralisation on the table names that you can't turn off, meaning that you have to add a declaration

{
    tableName:'<actual-table-name-rather-than-pluralised-version>'
}

to most if not all models if you don't use the same pluralisation convention. This is as much a fault with sequelize-restful as it is with the generator but the models could be more strictly generated to match the schema.

MSSQL id isn't getting set with the primaryKey property in generation

I have the following table in mssql:

CREATE TABLE [Test].[dbo].[Domains](
    [id] [int] IDENTITY(1,1) PRIMARY KEY NOT NULL,
    [Name] [varchar](50) NOT NULL,
    [LastTested] [datetime] NULL
);

But when I generate the model, the model's coming out as:

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('Domains', {
    id: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    Name: {
      type: DataTypes.STRING,
      allowNull: false
    },
    LastTested: {
      type: DataTypes.DATE,
      allowNull: true
    }
  }, {
    tableName: 'Domains',
    freezeTableName: true
  });
};

Shouldn't it get generated with the primaryKey property on id?

Cannot read property 'TABLE_SCHEMA' of undefined

My globally installed packages are:

[email protected]
[email protected]
[email protected]
[email protected]

and I am trying to run:

c:\>sequelize-auto -d toto -h localhost -u sa -p 1433 -x supersecret -e mssql -o "./models"

which gives me:

Unhandled rejection TypeError: Cannot read property 'TABLE_SCHEMA' of undefined.

I can successfully run my select:
SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES;
on my SQL SERVER 2014 (not sqlexpress)

I can successfully run raw select via given connection params in my app

Here is fullstack of error

Unhandled rejection TypeError: Cannot read property 'TABLE_SCHEMA' of undefined at C:\Users\murat.oguzalp\AppData\Roaming\npm\node_modules\sequelize-auto\li b\index.js:43:34 at C:\Users\murat.oguzalp\AppData\Roaming\npm\node_modules\sequelize-auto\no de_modules\async\lib\async.js:187:20 at C:\Users\murat.oguzalp\AppData\Roaming\npm\node_modules\sequelize-auto\no de_modules\async\lib\async.js:239:13 at _arrayEach (C:\Users\murat.oguzalp\AppData\Roaming\npm\node_modules\seque lize-auto\node_modules\async\lib\async.js:91:13) at _each (C:\Users\murat.oguzalp\AppData\Roaming\npm\node_modules\sequelize- auto\node_modules\async\lib\async.js:82:13) at Object.async.forEachOf.async.eachOf (C:\Users\murat.oguzalp\AppData\Roami ng\npm\node_modules\sequelize-auto\node_modules\async\lib\async.js:238:9) at Object.async.forEach.async.each (C:\Users\murat.oguzalp\AppData\Roaming\n pm\node_modules\sequelize-auto\node_modules\async\lib\async.js:215:22) at C:\Users\murat.oguzalp\AppData\Roaming\npm\node_modules\sequelize-auto\li b\index.js:33:13 at tryCatcher (C:\Users\murat.oguzalp\AppData\Roaming\npm\node_modules\seque lize-auto\node_modules\bluebird\js\main\util.js:26:23) at Promise._settlePromiseFromHandler (C:\Users\murat.oguzalp\AppData\Roaming \npm\node_modules\sequelize-auto\node_modules\bluebird\js\main\promise.js:507:31 ) at Promise._settlePromiseAt (C:\Users\murat.oguzalp\AppData\Roaming\npm\node _modules\sequelize-auto\node_modules\bluebird\js\main\promise.js:581:18) at Promise._settlePromises (C:\Users\murat.oguzalp\AppData\Roaming\npm\node_ modules\sequelize-auto\node_modules\bluebird\js\main\promise.js:697:14) at Async._drainQueue (C:\Users\murat.oguzalp\AppData\Roaming\npm\node_module s\sequelize-auto\node_modules\bluebird\js\main\async.js:123:16) at Async._drainQueues (C:\Users\murat.oguzalp\AppData\Roaming\npm\node_modul es\sequelize-auto\node_modules\bluebird\js\main\async.js:133:10) at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\murat.oguzalp\App Data\Roaming\npm\node_modules\sequelize-auto\node_modules\bluebird\js\main\async .js:15:14) at processImmediate [as _immediateCallback] (timers.js:374:17)

Example command

Into the example add "node" at the begging of the command (before sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres)

Auto increment missing in postgreSQL?

I have a table:

CREATE TABLE "user"
(
  user_id serial NOT NULL,
  CONSTRAINT pk_user PRIMARY KEY (user_id)
)

And a result is:

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('user', {
    user_id: {
      type: DataTypes.INTEGER,
      primaryKey: true
    }
  }, {
    tableName: 'user',
    freezeTableName: true,
    timestamps: false,
  });
};

However I expected to see "autoIncrement: true" for the "user_id" column.

I'm new to postgreSQL db, but I believe auto increment should be there.

Postgres - default TIMESTAMP value causing error

Steps to reproduce:
Table

CREATE TABLE test
(
    id          SERIAL        NOT NULL,
    sometime    TIMESTAMP     WITH TIME ZONE NOT NULL DEFAULT NOW(),

    CONSTRAINT  test_pk       PRIMARY KEY (id)
);

info.json

{
  "timestamps"      : false,
  "underscored"     : true,
  "freezeTableName" : true
}

Run

$ sequelize-auto -a info.json -d db_name -h localhost -u postgres -p 5432 -x postgres -e postgres 

Generated model

/* jshint indent: 2 */

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('test', {
    id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true,
      autoIncrement: true
    },
    sometime: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: 'now()'             // <--- this 'now()' causes error
    }
  }, {
    tableName: 'test',
    timestamps: false,
    underscored: true,
    freezeTableName: true
  });
};

Main point of test code is to create entity with default value for timestamp:

const Sequelize = require('sequelize')
const sequelize = new Sequelize('db_name', 'postgres', 'postgres', { dialect:'postgres' })
const TestModel = sequelize.import(__dirname + '/sequelize-models/test')

TestModel.create()
  .then (showResult)
  .catch(onError)

function showResult(result) { console.log(result) }
function onError   (err)    { console.error(err)  }

Error is

 { [error: invalid input syntax for type timestamp with time zone: "Invalid date"]
   ... 
   sql: 'INSERT INTO "test" ("id","sometime") VALUES (DEFAULT,\'Invalid date\') RETURNING *;' },

Temporary fix in my case is to change

      defaultValue: 'now()' 
      to
      defaultValue: new Date()

But that is really temporary as on production server timezone will be different, thus default value should be taken from server. So generated query should be:

INSERT INTO "test" ("id","sometime") VALUES (DEFAULT, NOW()) RETURNING *;
OR
INSERT INTO "test" ("id","sometime") VALUES (DEFAULT, DEFAULT) RETURNING *;
OR
INSERT INTO "test" ("id") VALUES (DEFAULT) RETURNING *;
etc..

Generate models with 'timestamps: false"

Here I am working with a database that is already in production and I cant afford to implement the sequelize timestamps (createdat and deletedat).

I would really like to see a option that gets a more raw data from the database, like a --notimestamps.

Update:
Actually I tried to use the -a flag with the json described bellow, and no luck.

{
  "timestamps": false
}

Does not set primary key if column isn't `id`

One of my database tables had a primary key column which was the name of another table's id like so:

playthrough.id == scores.playthroughid where scores has a primary key of playthroughid. For whatever reason, this wasn't picked up by sequelize-auto, and I had to manually add primaryKey: true for it to work when I setup my associations.

Bug: Foreign key detection not working for sqlite

πŸ‘‹ I'm trying to generate the same models for different dialects:

screenshot from 2016-01-02 19 32 52

And it turns out that sequelize-auto doesn't expect the correct data structure returned after executing PRAGMA foreign_key_list(table);:

screenshot from 2016-01-02 19 37 08

Hence the above code fails always, I guess that's why I'm not getting the references key in the model?

Let me know if I need to supply more information.

Better documentation for config

There should be somewhere that explains how to use the config, also in this config, it would be a good idea to define which column are defined with default values

Columns for foreign key are tagged as primary key

Hi.. I used your great module and I noticed that columns which are part of foreign key are tagged as "primary key", but they should be tagged as "references: {model: 'ModelName', key: 'keyName'}. I'm using PostgreSQL database and inside this database, these columns are part of foreign key.

It will be great to correct that issue if possible.

Thank you very much

Auto generate primaryKey and autoIncrement

Dear All,

I have used sequelize-auto to auto generate data model with DB MySQL. And the lib generate well.
But It is not auto generate primaryKey and autoIncrement for primary key field in DB.
Could anyone help me config to auto gen these field.

Thanks so much.

Missing foreign key

Hi,
I'm using sequelize-auto to auto generate data model with DB MySQL. Everything seems go well but foreignKey aren't auto generate in models.

Options for config.json

i think there should be an explanation on what can be set in the configuration file, or atleast how it is structured

Unhandled rejection TypeError: undefined is not a function : lib\index.js:100:59 mssql dialect

Received this error when attempting to run against 'mssql' dialect (see hack in #12)

Unhandled rejection TypeError: undefined is not a function
    at .....\node_modules\sequelize-auto\lib\index.js:100:59
    at Array.forEach (native)
    at .....\node_modules\sequelize-auto\lib\index.js:77:25
    at Array.forEach (native)
    at .....\node_modules\sequelize-auto\lib\index.js:63:18
    at .....\node_modules\sequelize-auto\node_modules\async\lib\async.js:187:20
    at .....\node_modules\sequelize-auto\node_modules\async\lib\async.js:239:13
    at _arrayEach (.....\node_modules\sequelize-auto\node_modules\async\lib\async.js:91:13)
    at _each (.....\node_modules\sequelize-auto\node_modules\async\lib\async.js:82:13)

    at Object.async.forEachOf.async.eachOf (.....\node_modules\sequelize-auto\node_modules\async\lib\async.js:238:9)
    at Object.async.forEach.async.each (.....\node_modules\sequelize-auto\node_modules\async\lib\async.js:215:22)
    at .....\node_modules\sequelize-auto\lib\index.js:51:15
    at .....\node_modules\sequelize-auto\node_modules\async\lib\async.js:52:16
    at done (.....\node_modules\sequelize-auto\node_modules\async\lib\async.js:248:21)

    at .....\node_modules\sequelize-auto\node_modules\async\lib\async.js:44:16
    at .....\node_modules\sequelize-auto\lib\index.js:47:13

interacting with the heroku

Hi,

Trying to generate the models from the Heroku db, received the next error:

ERR: error: no pg_hba.conf entry for host "IP", user "user", database "database", SSL off

As I understand the case is in the SSL. Do we have any method to overcome this?

Regards,

Generate a single model

Add a function to generate a single model for a specific table instead of all models from the whole database

Missing autoIncrement property in MSSQL

Looks like for MSSQL, the generators aren't adding the autoIncrement property to identity columns. Only discovered this because POSTs will throw a NULL exception if it's not there.

Here's the SQL create since my sql writting skills are a bit rusty:

USE [Test]
GO

/****** Object:  Table [dbo].[Content]    Script Date: 3/29/2016 12:20:17 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Content](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [Contents] [text] NOT NULL,
 CONSTRAINT [PK_Contents] PRIMARY KEY CLUSTERED 
(
    [id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

Definition

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('Content', {
    id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    Contents: {
      type: DataTypes.TEXT,
      allowNull: false
    }
  }, {
    tableName: 'Content',
    freezeTableName: true
  });
};

Cannot call method 'createConnection' of undefined

When running against a wordpress mysql db, its throwing an error back at me.

var connection = mysql.createConnection(connectionConfig);
                           ^
TypeError: Cannot call method 'createConnection' of undefined
    at module.exports.connect (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:306:28)
    at Object.pool.Pooling.Pool.create (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:131:19)
    at createResource (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:258:13)
    at dispense (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:250:9)
    at Object.me.acquire (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/node_modules/generic-pool/lib/generic-pool.js:316:5)
    at null.fct (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/dialects/mysql/connector-manager.js:241:19)
    at null.<anonymous> (/usr/local/lib/node_modules/sequelize-auto/node_modules/sequelize/lib/emitters/custom-event-emitter.js:24:18)
    at processImmediate [as _immediateCallback] (timers.js:354:15

Char datatype not being used

Thanks for the great tool πŸ‘ made my day!

On a mysql DB - CHAR(XX) are not being transformed as DATATYPE.CHAR(XX) but as CHAR(XX)

This is causing sequelize-graphql issues when importing the models.

I added this line on index.js +217

else if (_attr.match(/^char/)) {
              var length = _attr.match(/\(\d+\)/);
              val = 'DataTypes.CHAR' + (!  _.isNull(length) ? length : '');
            }

And works as (I) expected.

Is this a real issue or a lack of deep understanding on my part?

Thanks

Doesn't work with belongsTo when non-standard foreign keys are present

If I have a DB with a table accounts but in another section, a badly-named foreign key userid tracking back to it, the generator does account for this when making the column reference in the define statement, but if I manually add belongsTo, it does not do this and instead looks for accountId.

Is this something I'm supposed to handle or can the generator do that for me?
Might be similar to #34

Aliases for table names for use as model names

It would be cool to have ability to define alias for table name to use as model name in import (-t CLI option).

For ex: sequelize-auto .... -t "tbl_Task as Task, tbl_Contact as Contact".

In generated models, aliases should become model's names and original table names should go to TableName property of model.

P.S. Auto generating models for Sequelize mean that you dealing with some legacy database (or 3d party database), so you have no control about table names. But working with nice model names in code will make whole work nicer.

Support for Azure SQL Database?

I am executing the following command, but it fails to produce any models. The database is an Azure SQL Database:

  sequelize-auto -o "./models" -h <myserver> -p 1433 -d <mydatabase> -u <myuser> -x <mypasswd> --dialect mssql -c "./config/auto.json"

My config json looks like this:

{
    "dialectOptions": {
            "encrypt": true
        }
}

And this is the output (note the timeout errors):

Executing (default): SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES;
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'County'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'Event'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'Product'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'District'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'database_firewall_rules'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'Address'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'CommodityBalance'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'DistributorProduct'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'DistrictProduct'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'DistrictDistributor'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'DistrictManufacturer'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'sysdiagrams'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'DistrictDetailsView'
{ [SequelizeDatabaseError: Timeout: Request failed to complete in 15000ms]
  name: 'SequelizeDatabaseError',
  message: 'Timeout: Request failed to complete in 15000ms',
  parent:
   { [RequestError: Timeout: Request failed to complete in 15000ms]
     message: 'Timeout: Request failed to complete in 15000ms',
     code: 'ETIMEOUT',
     sql: 'SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = \'DistrictDistributor\'' },
  original:
   { [RequestError: Timeout: Request failed to complete in 15000ms]
     message: 'Timeout: Request failed to complete in 15000ms',
     code: 'ETIMEOUT',
     sql: 'SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = \'DistrictDistributor\'' },
  sql: 'SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = \'DistrictDistributor\'' }
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'DirectorDetailView'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'Coop'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'RA_Lookup'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'Director'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'AllSales'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'AccountManager'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'Manufacturer'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'ProductUsage'
Executing (default): SELECT         ccu.table_name AS source_table         ,ccu.constraint_name AS constraint_name         ,ccu.column_name AS source_column         ,kcu.table_name AS target_table         ,kcu.column_name AS target_column       FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu       INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc           ON ccu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME       INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu            ON kcu.CONSTRAINT_NAME = rc.UNIQUE_CONSTRAINT_NAME           WHERE ccu.table_name = 'Distributor'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'County'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'Event'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'Product'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'District'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'database_firewall_rules'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'Address'
{ [SequelizeDatabaseError: Timeout: Request failed to complete in 15000ms]
  name: 'SequelizeDatabaseError',
  message: 'Timeout: Request failed to complete in 15000ms',
  parent:
   { [RequestError: Timeout: Request failed to complete in 15000ms]
     message: 'Timeout: Request failed to complete in 15000ms',
     code: 'ETIMEOUT',
     sql: 'SELECT c.COLUMN_NAME AS \'Name\', c.DATA_TYPE AS \'Type\', c.IS_NULLABLE as \'IsNull\', COLUMN_DEFAULT AS \'Default\', tc.CONSTRAINT_TYPE AS \'Constraint\' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = \'PRIMARY KEY\' WHERE t.TABLE_NAME = \'Event\'' },
  original:
   { [RequestError: Timeout: Request failed to complete in 15000ms]
     message: 'Timeout: Request failed to complete in 15000ms',
     code: 'ETIMEOUT',
     sql: 'SELECT c.COLUMN_NAME AS \'Name\', c.DATA_TYPE AS \'Type\', c.IS_NULLABLE as \'IsNull\', COLUMN_DEFAULT AS \'Default\', tc.CONSTRAINT_TYPE AS \'Constraint\' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = \'PRIMARY KEY\' WHERE t.TABLE_NAME = \'Event\'' },
  sql: 'SELECT c.COLUMN_NAME AS \'Name\', c.DATA_TYPE AS \'Type\', c.IS_NULLABLE as \'IsNull\', COLUMN_DEFAULT AS \'Default\', tc.CONSTRAINT_TYPE AS \'Constraint\' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = \'PRIMARY KEY\' WHERE t.TABLE_NAME = \'Event\'' }
Done!
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'CommodityBalance'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'DistributorProduct'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'DistrictProduct'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'DistrictDistributor'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'DistrictManufacturer'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'sysdiagrams'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'DistrictDetailsView'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'DirectorDetailView'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'Coop'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'RA_Lookup'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'Director'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'AllSales'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'AccountManager'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'Manufacturer'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'ProductUsage'
Executing (default): SELECT c.COLUMN_NAME AS 'Name', c.DATA_TYPE AS 'Type', c.IS_NULLABLE as 'IsNull', COLUMN_DEFAULT AS 'Default', tc.CONSTRAINT_TYPE AS 'Constraint' FROM INFORMATION_SCHEMA.TABLES t INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON t.TABLE_NAME = c.TABLE_NAME AND t.TABLE_SCHEMA = c.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu ON t.TABLE_NAME = cu.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND t.TABLE_SCHEMA = cu.TABLE_SCHEMA LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc ON t.TABLE_NAME = tc.TABLE_NAME AND cu.COLUMN_NAME = c.COLUMN_NAME AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY' WHERE t.TABLE_NAME = 'Distributor'

Am I doing something wrong???

Support to generate the associate fn when generating models in MSSQL?

I'm curious if there's already functionality, on generation, to automatically include any hasMany, hasOne associations in the defines. If there is, it's not working in MSSQL.

If there isn't, it'd be nice to have since, every time I regenerate the models, I have to put back in the associate manually and it's getting tedious.

Also, as of the current version, what's the way to at least define that logic elsewhere and have it included in generation? The docs make reference of it, but I can't figure out the structure for defining it for multiple models. I can't do it in json because functions aren't valid in .json file format.

For instance, I have these two models that I'm putting the associate fn in manually:

module.exports = function(sequelize, DataTypes) {
  return sequelize.define('UseCase', {
    id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    ResourcesID: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'Resource',
        key: 'id'
      }
    },
    Description: {
      type: DataTypes.STRING,
      allowNull: false
    },
    LastTested: {
      type: DataTypes.DATE,
      allowNull: true
    },
    IsSuccess: {
      type: 'BIT',
      allowNull: true
    }
  }, {
    tableName: 'UseCase',
    freezeTableName: true,
    classMethods: {
      associate: function(models) {
        this.hasMany(models.Param);
      }
    }
  });
};
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('Param', {
    id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      primaryKey: true
    },
    UseCasesID: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'UseCase',
        key: 'id'
      }
    },
    Name: {
      type: DataTypes.STRING,
      allowNull: false
    },
    Value: {
      type: DataTypes.TEXT,
      allowNull: false
    },
    LastTested: {
      type: DataTypes.DATE,
      allowNull: true
    },
    IsSuccess: {
      type: 'BIT',
      allowNull: true
    }
  }, {
    tableName: 'Param',
    freezeTableName: true,
    classMethods: {
      associate: function(models) {
        this.hasMany(models.Content);
      }
    }
  });
};

I assume the include file would be something like:

module.exports = {
  'UseCase': {classMethods: {
    associate: function(models){
      this.hasMany(models.Param);
    }
  }},
  'Param': {classMethods: {
    associate: function(models){
      this.hasMany(models.Content);
    }
  }}
}

Is that how you structure it so that it'll be included in the generation? A concrete example would help in this situation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.