You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
! Feature can be implemented only in cphalcon repo
List of required changes
Phalcon\Db\Adapter\Pdo\Postgresql::createTable() major behavior changes
Phalcon\Db\Adapter\Pdo\Postgresql::addColumn() major behavior changes
Phalcon\Db\Adapter\Pdo\Postgresql::modifyColumn() major behavior changes
Phalcon\Db\Column adding new property 'function'
Phalcon\Db\Column adding new column type 'Column::TYPE_UUID'
Requirement of possible default functions list
As far i researched, to implement this, you need to know at least list of possible default_value functions.
# Example list of functions (procedures) for uuid
uuid_generate_v1()
uuid_generate_v1mc()
uuid_generate_v3()
uuid_generate_v4()
uuid_generate_v5()
uuid_nil()
uuid_ns_dns()
uuid_ns_oid()
uuid_ns_url()
uuid_ns_x500()
The reason we need possible default functions list is
SELECT * FROM information_schema.columns WHERE table_name = 'tbl';
Describe just returns default value without telling us is it a function or just a text.
Another approach - some magic to detect whether default value is text or function - to point braces as prefix ()
Example of uuid pkey setup
# Ensure uuid procedures available
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
# Creating table with uuid pkey column
CREATE TABLE "tbl" (
"pkey" UUID NOT NULL DEFAULT 'uuid_generate_v4()',
PRIMARY KEY ("pkey")
);
# Altering table with uuid pkey column
ALTER TABLE "tbl" ALTER COLUMN "pkey" SET DATA TYPE UUID USING (uuid_generate_v4());
Currently it is impossible to do this via morph(), only by executing manually the alter query. We need to change a lot in own Phalcon\Db component to achieve desired..
It will be cool if we can add a default function value for the column
Beautiful solution
The text was updated successfully, but these errors were encountered: