Hello everyone!
My purpouse is create a table with the first column having a default value taken from a sequence
This is the code i wrote so far to create the table
public function createTable() {
$seqExpr = new \Laminas\Db\Sql\Expression('nextval(\'prodotti_polizze_id_seq\'::regclass)');
$table = new Ddl\CreateTable($this->table_name);
$table->addColumn(new Ddl\Column\Integer('id', false, $seqExpr));
$table->addColumn(new Ddl\Column\Integer('compagnia', true));
$table->addColumn(new Ddl\Column\Integer('ramo', false));
$table->addColumn(new Ddl\Column\Integer('desc_ramo', false));
$table->addColumn(new Ddl\Column\Varchar('cod_prodotto', null, false));
$table->addConstraint(new Ddl\Constraint\PrimaryKey('cod_prodotto', 'cod_prodotto_pkey'));
$table->addConstraint(new Ddl\Constraint\UniqueKey('cod_prodotto', 'cod_prodotto_ukey'));
$table->addColumn(new Ddl\Column\Text('desc_prodotto'));
$sql = new Sql($this->db);
$this->db->query(
$sql->buildSqlString($table),
\Laminas\Db\Adapter\Adapter::QUERY_MODE_EXECUTE
);
}
but i couldnt find any instruction on the docs on how to create a sequence (in this case prodotti_polizze_id_seq)