[英]How can i translate this code written from php in adonisJS?
I have a bunch of code in PHP, and I want to translate it into AdonisJS. 我在PHP中有一堆代码,我想将其翻译成AdonisJS。
I have a table from a database here and I want to make a migration to Adonis with this code. 我在这里有一个数据库表,我想用此代码迁移到Adonis。
This is the default code in PHP: 这是PHP中的默认代码:
$schema = new \Doctrine\DBAL\Schema\Schema();
$myTable = $schema->createTable("user_comenzi");
$myTable->addColumn("id", "integer", array("unsigned" => true,"autoincrement"=>true));
$myTable->addColumn("user_id", "integer", array("unsigned" => true));
$myTable->addColumn("adresa_id", "integer", array("unsigned" => true));
$myTable->addColumn("creat", "datetime", array());
$myTable->addColumn("status", "integer", array("default"=>0));
$myTable->addColumn("comanda", "text");
$myTable->setPrimaryKey(array("id"));
//$schema->createSequence("comenzi_seq");
$platform = new \Doctrine\DBAL\Platforms\SqlitePlatform();
$queries = $schema->toSql($platform); // get queries to create this schema.
print_r($queries);
$app['db']->query($queries[0]);
And it's supposed to be something like this in AdonisJS: 在AdonisJS中应该是这样的:
class UserComenziSchema extends Schema {
up () {
this.create('user_comenzi', (table) => {
table.increments()
table.integer('user_id').unsigned()
table.integer('adresa_id').unsigned()
table.time('creat')
table.integer('status').defaultTo(0)
table.text('comanda')
table.timestamps()
})
}
down () {
this.drop('user_comenzi')
}
}
I want just to see if my code is wrong or not, and if I'm wrong, why? 我只想看看我的代码是否错误,如果我错了,为什么?
将table.time('creat')
更改为table.datetime('creat')
即可
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.