martinjw / dbschemareader

Read database metadata (from SqlServer/Oracle/MySql/SQLite/PostgreSql/DB2 etc) into one simple model
Microsoft Public License
293 stars 127 forks source link

PostgreSqlMigrationGenerator.AlterColumn does not handle DateTimeOffSet DbType correctly #155

Closed groogiam closed 1 year ago

groogiam commented 1 year ago

The PostgreSqlMigrationGenerator.AlterColumn does not handle DateTimeOffSet DbType correctly. It seems to generate conversion logic that does uses DateTimeOffSet instead of the correct timestampz type. See below generated output.

-- project from authorizationdate TIMESTAMP (6) to AuthorizationDate DATETIMEOFFSET
ALTER TABLE project ALTER COLUMN AuthorizationDate TYPE DATETIMEOFFSET USING CAST(AuthorizationDate AS DATETIMEOFFSET);
ALTER TABLE project ALTER COLUMN AuthorizationDate DROP NOT NULL;

This generates the following error

ScriptExecutionError: 42704: type "datetimeoffset" does not exist

The data type in the script should be timestampz. The data type is correctly generated when using the AddColumn operation but not when changing data type.

groogiam commented 1 year ago

This was an issue in my code. The table I was using to add / modify the column did not have the correct database type set on it due to a logic error in my code.