Open neekey opened 10 years ago
According to my test (using db.sync) and sql-ddl-sync/lib/Dialects/mysql.js, it creates longtext.
package.json
"mysql": "~2.0.0-alpha9",
"orm": "^2.1.15",
model definition in badge.js
db.define('badge', {
name: { type: 'text', big:true },
image: { type: 'text', size: 128 }
}, {
methods: {
}
});
result using connection.debug
(orm/mysql) CREATE TABLE `badge` (`name` LONGTEXT, `image` VARCHAR(128), `id` INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`))
@mike-zenith update to orm@2.1.15 gets it work, but encountered another problem for me : field type text
with big
option can not have defaultValue
According to the [mysql doco]:
BLOB and TEXT columns cannot have DEFAULT values. so this is a mysql limitation.
Unfortunately, orm doesn't discriminate between database set default values & ones set in the javascript code so default values for big text with mysql will fail. I recommend Postgres.
below is my model definition:
i use
data
to store very long data string, so i use big ( by default orm2 just set varchar(255) fortext
), but when I set big to true, orm2 just doesn't create the table for me, if removebig
it works fine.