Closed sujit-baniya closed 4 years ago
Hi,
you can use primary
and bigPrimary
. If you want to use UUID you can use alternative declaration:
https://cycle-orm.dev/docs/advanced-uuid
To use auto-timestamps you have to use your own mapper, the example is here: https://cycle-orm.dev/docs/advanced-timestamp
You do not need to write migrations manually, use the command for that:
$ php app.php cycle:migrate
So I can't define timstamp iis simple way
If I use mapper something like this:
/**
* @Cycle\Entity(repository="\App\Repository\AccountRepository", mapper="TimestampedMapper")
*/
class Account
Will the fields: created_at and updated_at automatically defined or I need to define it like this way
<?php
/**
* {project-name}
*
* @author {author-name}
*/
declare(strict_types=1);
namespace App\Database;
use Cycle\Annotated\Annotation as Cycle;
/**
* @Cycle\Entity(repository="\App\Repository\AccountRepository", mapper="TimestampedMapper")
*/
class Account
{
/**
* @Cycle\Column(type = "primary")
*/
public $id;
/**
* @Cycle\Column(type = "string")
*/
public $name;
/**
* @Cycle\Column(type = "timestamp", default="CURRENT_TIMESTAMP")
*/
public $created_at;
/**
* @Cycle\Column(type = "timestamp", default="CURRENT_TIMESTAMP")
*/
public $updated_at;
}
If you use second example from article with Table annotation columns will be added automatically but you still have to declare fields. We do not have one liner for it yet.
Do not use timestams unless you want to stick to one database type only.
oh okay! Thanks
how to add BigInt as primary auto increment key in migration?
Also I don't see the option to add Auto Increment as option.
How to add other options for fields in migration like: