Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres Error during Install #8

Open
vardumper opened this issue Apr 10, 2024 · 3 comments · Fixed by #10
Open

Postgres Error during Install #8

vardumper opened this issue Apr 10, 2024 · 3 comments · Fixed by #10
Assignees

Comments

@vardumper
Copy link

This happened on Craft 5.0.3, PHP 8.3, Postgres 16 on DDEV

Copy Stacktrace Search Stackoverflow Search Google Exception
Migration Error – craft\errors\MigrationException

An error occurred while executing the "statikbe\carbontracker\migrations\Install migration: SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "green" is of type boolean but default expression is of type integer
HINT: You will need to rewrite or cast the expression.
The SQL being executed was: CREATE TABLE "carbontracker_stats" (
"id" serial NOT NULL PRIMARY KEY,
"entryId" integer NOT NULL,
"siteId" integer NOT NULL,
"url" varchar(255) NOT NULL,
"green" boolean DEFAULT 0,
"bytes" integer,
"cleanerThan" double precision DEFAULT 0,
"rating" varchar(2),
"dateCreated" timestamp(0) NOT NULL,
"dateUpdated" timestamp(0) NOT NULL,
"dateDeleted" timestamp(0) NULL DEFAULT NULL,
"uid" char(36) NOT NULL DEFAULT '0'
)
↵
Caused by: Database Exception – [yii\db\Exception](https://www.yiiframework.com/doc-2.0/yii-db-exception.html)

SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "green" is of type boolean but default expression is of type integer
HINT: You will need to rewrite or cast the expression.
The SQL being executed was: CREATE TABLE "carbontracker_stats" (
"id" serial NOT NULL PRIMARY KEY,
"entryId" integer NOT NULL,
"siteId" integer NOT NULL,
"url" varchar(255) NOT NULL,
"green" boolean DEFAULT 0,
"bytes" integer,
"cleanerThan" double precision DEFAULT 0,
"rating" varchar(2),
"dateCreated" timestamp(0) NOT NULL,
"dateUpdated" timestamp(0) NOT NULL,
"dateDeleted" timestamp(0) NULL DEFAULT NULL,
"uid" char(36) NOT NULL DEFAULT '0'
)

in /var/www/html/vendor/yiisoft/yii2/db/Schema.php at line 676
Error Info: Array
(
    [0] => 42804
    [1] => 7
    [2] => ERROR:  column "green" is of type boolean but default expression is of type integer
HINT:  You will need to rewrite or cast the expression.
)
↵
Caused by: PDOException

SQLSTATE[42804]: Datatype mismatch: 7 ERROR: column "green" is of type boolean but default expression is of type integer
HINT: You will need to rewrite or cast the expression.

in /var/www/html/vendor/yiisoft/yii2/db/Command.php at line 1302

Hope this is useful.

@janhenckens janhenckens self-assigned this Apr 10, 2024
@janhenckens
Copy link
Member

I don't have much postgres expierence but I assume this line is the problem:

'green' => $this->boolean()->defaultValue(0),

I'll see if changing the default value to false fixes the issue.

@janhenckens
Copy link
Member

Should be fixed in 5.0.1, @vardumper can you give that a try? Thanks!

@vardumper
Copy link
Author

vardumper commented Apr 11, 2024

Sure thing, I'll ping you here later on. Yep, I could now install the plugin. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants