<p>Finally I was able to debug and fix the problem.</p>
<p>The use of a specific schema in the PosgreSQL DB (instead of <code>public</code>) caused the problem. But not the fact itself was problematic, instead the schema was missing in the Postgres <code>search_path</code>.</p>
<p>Fixing the <code>search_path</code> also fixed the problem.</p>

CC BY-SA 4.0
2023-03-15T21:32:10.837Z
Ahh... nice debugging and thanks for the follow-up!
Brad Bell
CC BY-SA 4.0
2023-03-15T11:09:18.867Z
2023-03-16T20:16:43.550Z
2023-03-16T20:16:43.550Z
Boris
<p>I am trying to install the Craft CMS (Version 4.4.1) on a VM in the Azure Cloud with PostgreSQL 13.9 as managed Azure Service.</p>
<p>The error i'm running into is the following:</p>
<pre><code>*** failed to install Craft: An error occurred while executing the &quot;craft\migrations\Install migration: SQLSTATE[23502]: Not null violation: 7 
ERROR:  null value in column &quot;dateCreated&quot; of relation &quot;info&quot; violates not-null constraint
DETAIL:  Failing row contains (1, 4.4.1, 4.4.0.4, f, jlynfdbhxzhh, junzvyhomsyt, null, null, 0).
The SQL being executed was: 
INSERT INTO &quot;info&quot; (&quot;version&quot;, &quot;schemaVersion&quot;, &quot;maintenance&quot;, &quot;configVersion&quot;, &quot;fieldVersion&quot;, &quot;id&quot;) VALUES ('4.4.1', '4.4.0.4', FALSE, 'jlynfdbhxzhh', 'junzvyhomsyt', 1)
</code></pre>
<p>Creation of tables, indexes and foreign keys just works fine. But as soon as the <code>info</code> table is being populated, the installation crashes with the error above.</p>
<p>The local docker setup installs just fine (configured with PostgreSQL too).</p>
<p>Any kind of help is highly appreciated!</p>

CC BY-SA 4.0
2023-03-14T22:48:24.823Z
Hrm... locally, were you using PostgreSQL 13.9 as well? The install migration calls Application::saveInfo, which ultimately calls Command::insert, which inserts the dateCreated, dateUpdated and uid column values if they don't exist: https://github.com/craftcms/cms/blob/develop/src/db/Command.php#L32-L43
Brad Bell
CC BY-SA 4.0
2023-03-15T06:24:06.100Z
Thank you @BradBell for your insights. When debugging the Commend::insert method, it turns out that the `dateCreated` checking condition evaluates to `false`. This is because `$this->db->columnExists($table, 'dateCreated')` itself evaluates to `false`. How can that be?
Boris
<installation><craft4><postgresql>
Craft installation fails with SQL error (PostgreSQL)
# Craft installation fails with SQL error (PostgreSQL)

(Asked by: username_0 on 2023-03-14)

I am trying to install the Craft CMS (Version 4.4.1) on a VM in the Azure Cloud with PostgreSQL 13.9 as managed Azure Service.
The error i'm running into is the following:
*** failed to install Craft: An error occurred while executing the "craft\migrations\Install migration: SQLSTATE[23502]: Not null violation: 7 
ERROR:  null value in column "dateCreated" of relation "info" violates not-null constraint
DETAIL:  Failing row contains (1, 4.4.1, 4.4.0.4, f, jlynfdbhxzhh, junzvyhomsyt, null, null, 0).
The SQL being executed was: 
INSERT INTO "info" ("version", "schemaVersion", "maintenance", "configVersion", "fieldVersion", "id") VALUES ('4.4.1', '4.4.0.4', FALSE, 'jlynfdbhxzhh', 'junzvyhomsyt', 1)

Creation of tables, indexes and foreign keys just works fine. But as soon as the info table is being populated, the installation crashes with the error above.
The local docker setup installs just fine (configured with PostgreSQL too).
Any kind of help is highly appreciated!

**Tags:** installation, craft4, postgresql
> **Comments:**
> **username_1**: Hrm... locally, were you using PostgreSQL 13.9 as well? The install migration calls Application::saveInfo, which ultimately calls Command::insert, which inserts the dateCreated, dateUpdated and uid column values if they don't exist: https://github.com/craftcms/cms/blob/develop/src/db/Command.php#L32-L43  
> **username_0**: Thank you @BradBell for your insights. When debugging the Commend::insert method, it turns out that the `dateCreated` checking condition evaluates to `false`. This is because `$this->db->columnExists($table, 'dateCreated')` itself evaluates to `false`. How can that be?  

---

## 1 answers

### Answer by username_0 on 2023-03-15. Score: 3

Finally I was able to debug and fix the problem.

The use of a specific schema in the PosgreSQL DB (instead of `public`) caused the problem. But not the fact itself was problematic, instead the schema was missing in the Postgres `search_path`.

Fixing the `search_path` also fixed the problem.

> **Comments:**
> **username_1**: Ahh... nice debugging and thanks for the follow-up!  

---

