<p>That error is because the <code>config/db.php</code> file is probably setting the <a href="https://craftcms.com/docs/4.x/config/db.html#schema" rel="nofollow noreferrer">schema</a> property to an empty string (or null), overwriting the default <code>public</code> value that Postgres uses.</p>

CC BY-SA 4.0
2022-12-15T22:39:45.373Z
Thanks Brad! That sorted it, silly me - I'd commented out the DB_SCHEMA env var.

Wrt to setting the unknown property 'schemaVersion', that related to the lowercase conversion when using the `pgloader from to` in it's rawest form.  Reverted to your answer in a similar q which resolved it, using a command file as the input - thanks for your help!
Rich D.
CC BY-SA 4.0
2022-12-16T02:25:40.343Z
No worries - glad you're all sorted!
Brad Bell
CC BY-SA 4.0
2023-02-06T19:07:40.423Z
@BradBell **what else could it be?**  I get the same php error like @Rich D. but with different stack trace start. 
`An Error occurred while handling another error:
yii\base\UnknownPropertyException: Setting unknown property: craft\models\Info::schemaversion in /app/vendor/yiisoft/yii2/base/Component.php:209 Stack trace:
#0 /app/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set()
#1 /app/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure()`
Dominik Krulak
CC BY-SA 4.0
2023-02-06T19:19:38.953Z
A note to add to my comment above is  that I migrated using Docker command because databases live in Docker containers. So I run something like `$ docker run --rm -it dimitri/pgloader:latest pgloader mysql://myuser@myhost/dbname pgsql://pguser@pghost/dbname`. After I just renamed _schema_ name to _public_. I quote your comment in [your question](https://craftcms.stackexchange.com/questions/35815/is-there-a-way-to-convert-a-craft-mysql-database-to-postgresql): _column names would all be lowercased, some critical type conversions and search index updates would be missing_. Could that be?
Dominik Krulak
CC BY-SA 4.0
2022-12-15T22:16:41.763Z
2022-12-15T22:16:41.763Z
Brad Bell
<p>I've managed to convert a fairly basic Craft 4 MySQL db to PostgreSQL using the pgloader tool, which came with it's own auth related issues when running PSQL v14+ instance - see <a href="https://github.com/dimitri/pgloader/issues/1183" rel="nofollow noreferrer">https://github.com/dimitri/pgloader/issues/1183</a> for solution, but it ran successfully in the end. Now when attempting to view the site locally it's throwing the following error, an issue with Craft specifically it seems:</p>
<pre><code>yii\base\UnknownPropertyException: Setting unknown property: craft\models\Info::schemaversion in /var/www/html/vendor/yiisoft/yii2/base/Component.php:209
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component-&gt;__set('schemaversion', '4.0.0.9')
</code></pre>
<p>Also I tried dropping/recreating the pg db and installing a fresh craft instance with <code>./craft install/craft</code> but that output the following:</p>
<pre><code>    &gt; populating the info table ... Exception: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near &quot;ORDER&quot;

*** failed to install Craft: An error occurred while executing the &quot;craft\migrations\Install migration: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near &quot;ORDER&quot;
LINE 60: ORDER BY
         ^
The SQL being executed was: SELECT
    d.nspname AS table_schema,
    c.relname AS table_name,
    a.attname AS column_name,
    COALESCE(td.typname, tb.typname, t.typname) AS data_type,
    COALESCE(td.typtype, tb.typtype, t.typtype) AS type_type,
    (SELECT nspname FROM pg_namespace WHERE oid = COALESCE(td.typnamespace, tb.typnamespace, t.typnamespace)) AS type_scheme,
    a.attlen AS character_maximum_length,
    pg_catalog.col_description(c.oid, a.attnum) AS column_comment,
    a.atttypmod AS modifier,
    a.attnotnull = false AS is_nullable,
    CAST(pg_get_expr(ad.adbin, ad.adrelid) AS varchar) AS column_default,
    coalesce(pg_get_expr(ad.adbin, ad.adrelid) ~ 'nextval',false) OR attidentity != '' AS is_autoinc,
    pg_get_serial_sequence(quote_ident(d.nspname) || '.' || quote_ident(c.relname), a.attname) AS sequence_name,
    CASE WHEN COALESCE(td.typtype, tb.typtype, t.typtype) = 'e'::char
        THEN array_to_string((SELECT array_agg(enumlabel) FROM pg_enum WHERE enumtypid = COALESCE(td.oid, tb.oid, a.atttypid))::varchar[], ',')
        ELSE NULL
    END AS enum_values,
    CASE atttypid
         WHEN 21 /*int2*/ THEN 16
         WHEN 23 /*int4*/ THEN 32
         WHEN 20 /*int8*/ THEN 64
         WHEN 1700 /*numeric*/ THEN
              CASE WHEN atttypmod = -1
               THEN null
               ELSE ((atttypmod - 4) &gt;&gt; 16) &amp; 65535
               END
         WHEN 700 /*float4*/ THEN 24 /*FLT_MANT_DIG*/
         WHEN 701 /*float8*/ THEN 53 /*DBL_MANT_DIG*/
         ELSE null
      END   AS numeric_precision,
      CASE
        WHEN atttypid IN (21, 23, 20) THEN 0
        WHEN atttypid IN (1700) THEN
        CASE
            WHEN atttypmod = -1 THEN null
            ELSE (atttypmod - 4) &amp; 65535
        END
           ELSE null
      END AS numeric_scale,
    CAST(
             information_schema._pg_char_max_length(information_schema._pg_truetypid(a, t), information_schema._pg_truetypmod(a, t))
             AS numeric
    ) AS size,
    a.attnum = any (ct.conkey) as is_pkey,
    COALESCE(NULLIF(a.attndims, 0), NULLIF(t.typndims, 0), (t.typcategory='A')::int) AS dimension
FROM
    pg_class c
    LEFT JOIN pg_attribute a ON a.attrelid = c.oid
    LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum
    LEFT JOIN pg_type t ON a.atttypid = t.oid
    LEFT JOIN pg_type tb ON (a.attndims &gt; 0 OR t.typcategory='A') AND t.typelem &gt; 0 AND t.typelem = tb.oid OR t.typbasetype &gt; 0 AND t.typbasetype = tb.oid
    LEFT JOIN pg_type td ON t.typndims &gt; 0 AND t.typbasetype &gt; 0 AND tb.typelem = td.oid
    LEFT JOIN pg_namespace d ON d.oid = c.relnamespace
    LEFT JOIN pg_constraint ct ON ct.conrelid = c.oid AND ct.contype = 'p'
WHERE
    a.attnum &gt; 0 AND t.typname != '' AND NOT a.attisdropped
    AND c.relname = 'info'
    AND d.nspname = 
ORDER BY
    a.attnum;
</code></pre>
<p>I'm running PostgreSQL <code>server 15.1 (Debian 15.1-1.pgdg110+1))</code>.</p>
<p>Any help appreciated, thanks!</p>

<migration><mysql><craft4><postgresql>
Migrating a Craft 4 instance from MySQL to PostgreSQL
# Migrating a Craft 4 instance from MySQL to PostgreSQL

(Asked by: username_0 on 2022-12-15)

I've managed to convert a fairly basic Craft 4 MySQL db to PostgreSQL using the pgloader tool, which came with it's own auth related issues when running PSQL v14+ instance - see https://github.com/dimitri/pgloader/issues/1183 for solution, but it ran successfully in the end. Now when attempting to view the site locally it's throwing the following error, an issue with Craft specifically it seems:
yii\base\UnknownPropertyException: Setting unknown property: craft\models\Info::schemaversion in /var/www/html/vendor/yiisoft/yii2/base/Component.php:209
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set('schemaversion', '4.0.0.9')

Also I tried dropping/recreating the pg db and installing a fresh craft instance with ./craft install/craft but that output the following:
    > populating the info table ... Exception: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "ORDER"

*** failed to install Craft: An error occurred while executing the "craft\migrations\Install migration: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "ORDER"
LINE 60: ORDER BY
         ^
The SQL being executed was: SELECT
    d.nspname AS table_schema,
    c.relname AS table_name,
    a.attname AS column_name,
    COALESCE(td.typname, tb.typname, t.typname) AS data_type,
    COALESCE(td.typtype, tb.typtype, t.typtype) AS type_type,
    (SELECT nspname FROM pg_namespace WHERE oid = COALESCE(td.typnamespace, tb.typnamespace, t.typnamespace)) AS type_scheme,
    a.attlen AS character_maximum_length,
    pg_catalog.col_description(c.oid, a.attnum) AS column_comment,
    a.atttypmod AS modifier,
    a.attnotnull = false AS is_nullable,
    CAST(pg_get_expr(ad.adbin, ad.adrelid) AS varchar) AS column_default,
    coalesce(pg_get_expr(ad.adbin, ad.adrelid) ~ 'nextval',false) OR attidentity != '' AS is_autoinc,
    pg_get_serial_sequence(quote_ident(d.nspname) || '.' || quote_ident(c.relname), a.attname) AS sequence_name,
    CASE WHEN COALESCE(td.typtype, tb.typtype, t.typtype) = 'e'::char
        THEN array_to_string((SELECT array_agg(enumlabel) FROM pg_enum WHERE enumtypid = COALESCE(td.oid, tb.oid, a.atttypid))::varchar[], ',')
        ELSE NULL
    END AS enum_values,
    CASE atttypid
         WHEN 21 /*int2*/ THEN 16
         WHEN 23 /*int4*/ THEN 32
         WHEN 20 /*int8*/ THEN 64
         WHEN 1700 /*numeric*/ THEN
              CASE WHEN atttypmod = -1
               THEN null
               ELSE ((atttypmod - 4) >> 16) & 65535
               END
         WHEN 700 /*float4*/ THEN 24 /*FLT_MANT_DIG*/
         WHEN 701 /*float8*/ THEN 53 /*DBL_MANT_DIG*/
         ELSE null
      END   AS numeric_precision,
      CASE
        WHEN atttypid IN (21, 23, 20) THEN 0
        WHEN atttypid IN (1700) THEN
        CASE
            WHEN atttypmod = -1 THEN null
            ELSE (atttypmod - 4) & 65535
        END
           ELSE null
      END AS numeric_scale,
    CAST(
             information_schema._pg_char_max_length(information_schema._pg_truetypid(a, t), information_schema._pg_truetypmod(a, t))
             AS numeric
    ) AS size,
    a.attnum = any (ct.conkey) as is_pkey,
    COALESCE(NULLIF(a.attndims, 0), NULLIF(t.typndims, 0), (t.typcategory='A')::int) AS dimension
FROM
    pg_class c
    LEFT JOIN pg_attribute a ON a.attrelid = c.oid
    LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum
    LEFT JOIN pg_type t ON a.atttypid = t.oid
    LEFT JOIN pg_type tb ON (a.attndims > 0 OR t.typcategory='A') AND t.typelem > 0 AND t.typelem = tb.oid OR t.typbasetype > 0 AND t.typbasetype = tb.oid
    LEFT JOIN pg_type td ON t.typndims > 0 AND t.typbasetype > 0 AND tb.typelem = td.oid
    LEFT JOIN pg_namespace d ON d.oid = c.relnamespace
    LEFT JOIN pg_constraint ct ON ct.conrelid = c.oid AND ct.contype = 'p'
WHERE
    a.attnum > 0 AND t.typname != '' AND NOT a.attisdropped
    AND c.relname = 'info'
    AND d.nspname = 
ORDER BY
    a.attnum;

I'm running PostgreSQL server 15.1 (Debian 15.1-1.pgdg110+1)).
Any help appreciated, thanks!

**Tags:** migration, mysql, craft4, postgresql

---

## 1 answers

### Answer by username_1 on 2022-12-15. Score: 0 | Accepted answer

That error is because the `config/db.php` file is probably setting the [schema](https://craftcms.com/docs/4.x/config/db.html#schema) property to an empty string (or null), overwriting the default `public` value that Postgres uses.

> **Comments:**
> **username_0**: Thanks Brad! That sorted it, silly me - I'd commented out the DB_SCHEMA env var.  Wrt to setting the unknown property 'schemaVersion', that related to the lowercase conversion when using the `pgloader from to` in it's rawest form.  Reverted to your answer in a similar q which resolved it, using a command file as the input - thanks for your help!  
> **username_1**: No worries - glad you're all sorted!  
> **username_2**: @BradBell **what else could it be?**  I get the same php error like @Rich D. but with different stack trace start.  `An Error occurred while handling another error: yii\base\UnknownPropertyException: Setting unknown property: craft\models\Info::schemaversion in /app/vendor/yiisoft/yii2/base/Component.php:209 Stack trace: #0 /app/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set() #1 /app/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure()`  
> **username_2**: A note to add to my comment above is  that I migrated using Docker command because databases live in Docker containers. So I run something like `$ docker run --rm -it dimitri/pgloader:latest pgloader mysql://myuser@myhost/dbname pgsql://pguser@pghost/dbname`. After I just renamed _schema_ name to _public_. I quote your comment in [your question](https://craftcms.stackexchange.com/questions/35815/is-there-a-way-to-convert-a-craft-mysql-database-to-postgresql): _column names would all be lowercased, some critical type conversions and search index updates would be missing_. Could that be?  

---

