1602 / jugglingdb

Multi-database ORM for nodejs: redis, mongodb, mysql, sqlite3, postgresql, arango, in-memory...
http://1602.github.io/jugglingdb/
2.04k stars 241 forks source link

foreign key doesnt create in mysql #347

Closed frontend-3 closed 10 years ago

frontend-3 commented 10 years ago

Foreign key doesnt create in mysql

frontend-3 commented 10 years ago

var Movie = schema.define('Movie', { title: { type: String, length: 150 }, sinopsis: { type: String, length: 255 }, url_trailer: { type: String, length: 150 }, type: { type: String, length: 30 }, casting: { type: String, length: 255 }, duration: { type: String, length: 10 }, date: { type: Date}, country: { type: String, length: 100 }, director: { type: String, length: 100 }

});

var Movie_detail = schema.define('Movie_detail', { movie_id: { type: Number, dataType: 'int'}, showtime: { type: String, length: 10 }, point_id: { type: Number, dataType: 'int'} });

Movie_detail.belongsTo(Movie, {as: 'movie', foreignKey: 'movie_id'});

schema.automigrate();

Doesnt work

dgsan commented 10 years ago

https://github.com/jugglingdb/mysql-adapter/issues/14

So far as I know relations test does pass currently, though: https://github.com/1602/jugglingdb/blob/master/test/relations.test.js.

1602 commented 10 years ago

Not confirmed:

$ node test.js
CREATE TABLE `Movie` (
  `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `title` VARCHAR(150) NULL,
  `sinopsis` VARCHAR(255) NULL,
  `url_trailer` VARCHAR(150) NULL,
  `type` VARCHAR(30) NULL,
  `casting` VARCHAR(255) NULL,
  `duration` VARCHAR(10) NULL,
  `date` DATETIME NULL,
  `country` VARCHAR(100) NULL,
  `director` VARCHAR(100) NULL
)
CREATE TABLE `Movie_detail` (
  `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `movie_id` int(11) NULL,
  `showtime` VARCHAR(10) NULL,
  `point_id` int(11) NULL
)
frontend-3 commented 10 years ago

Not created foreign key