node-orm同步到Alter Tables(类似于DataMapper.auto_upgrade)

我正在使用node-orm尝试设置我的数据库。 这是模型代码。

db = orm.connect("mysql", client, (success, db) -> Strain = db.define("strain", name: type: "string" validations: [ orm.validators.unique() ] old_body: type: "string" body: type: "string" created_at: type: "date" update_at: type: "date" ) Strain.sync() ) 

我将/orm/lib/databases/mysql.js文件更改为console.log返回的同步信息。

 this._client.query(_query, function (err, info) { console.log(err); console.log(info); console.log("collection synced"); }); 

Strain.sync()第一次运行,这是输出。

 null { affectedRows: 0, insertId: 0, serverStatus: 2, warningCount: 0, message: '', setMaxListeners: [Function], emit: [Function], addListener: [Function], on: [Function], once: [Function], removeListener: [Function], removeAllListeners: [Function], listeners: [Function] } collection synced 

现在,表格就是应该创build的。 当我重新启动服务器并再次运行Strain.sync()时,这是输出:

 null { affectedRows: 0, insertId: 0, serverStatus: 2, warningCount: 1, message: '', setMaxListeners: [Function], emit: [Function], addListener: [Function], on: [Function], once: [Function], removeListener: [Function], removeAllListeners: [Function], listeners: [Function] } collection synced 

警告计数跳到“1”,但err为空,消息为空。

我需要弄清楚如何改变模型,并添加一个新的属性,如“deleted_at”,并更新表没有丢失数据。 我知道我可以做Strain.sync(force:true),但是会删除表格然后重新创build它。 我只是想更新表,类似于DataMapper的auto_upgrade函数。

有没有办法做到这一点与node-orm,或任何与nodejs工作的ORM?

很确定当前版本的sync()只创build表,不更新。

注意:sync()目前只创build表; 表格修改将在即将到来的版本中添加。

https://github.com/dresende/node-orm#creating-the-model-on-the-database