Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-15T21:32:10.837Z
Answers.Text: Ahh... nice debugging and thanks for the follow-up!
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-15T11:09:18.867Z
Answers.LastActivityDate: 2023-03-16T20:16:43.550Z
Answers.LastEditDate: 2023-03-16T20:16:43.550Z
Answers.UserDisplayName: Boris
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-14T22:48:24.823Z
Comments.Text: 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
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-15T06:24:06.100Z
Comments.Text: 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?
Comments.UserDisplayName: Boris
Tags: <installation><craft4><postgresql>
Title: Craft installation fails with SQL error (PostgreSQL)
ThreadText: # 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 @username_1 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!  
  
  ---
  
  