orm icon indicating copy to clipboard operation
orm copied to clipboard

Unable to use custom type in migrations

Open sartor opened this issue 5 years ago • 1 comments

I want to use GENERATED ALWAYS AS IDENTITY type instead of serial. Now I can't find any way to use it. Here is my sample migration (don't work now)

class InitMigration extends Migration
{
    public function up()
    {
        $this->table('users')
            ->addColumn('id', 'INTEGER GENERATED ALWAYS AS IDENTITY', [
                'nullable' => false,
            ])
            ->addColumn('email', 'string', [
                'nullable' => false,
                'size'     => 250
            ])
            ->create();
    }

    public function down()
    {
        $this->table('users')->drop();
    }
}

Is there any way to create IDENTITY column instead of serial?

sartor avatar Oct 02 '20 15:10 sartor

The identity columns might be not supported via declarative form. Try using native queries. We will extend declarative builder to support user types later.

$this->database()->execute();

wolfy-j avatar Oct 05 '20 08:10 wolfy-j