<p>I am trying to migrate a SQLite dump to PostgreSQL deployed on Kubernetes but I am having issues connecting the dots.</p>

<p>I have created a SQLite dump using the following command:</p>

<p><code>sqlite3 sqlite.db .dump &gt; dump.sql</code></p>

<p>Now, I want to migrate it to my Kubernetes deployment.
I have connected to it using:</p>

<p><code>psql -h &lt;external IP of node&gt; -U postgresadmin --password -p &lt;port that i got using kubectl get svc postgres&gt;</code></p>

<p>Everything seems to work so far, it is now I run into problems that resulted in me having two questions!</p>

<ol>
<li>I have seen some question regarding migrating SQLite to PostgreSQL, and it seems this command will do that:
<code>psql /path/to/psql -d database -U username -W &lt;
/the/path/to/dump.sql</code>. Will I have to create the same tables (empty but with same columns etc.) in PostgreSQL if the dump contains several tables, or will this command do this automatically? I believe I do, based on output I share in question 2, but will it also move on automatically to the next table?</li>
<li>How do I combine the command in question 1 to migrate it to the kubernetes deployment? I tried with adding <code>&lt; dump.sql</code> to the command I used connecting to it but got the following output:</li>
</ol>

<pre><code>CREATE TABLE
INSERT 0 1
ERROR:  relation "first_report" does not exist
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  current transaction is aborted, commands ignored until end of transaction block

</code></pre>

<p>So, obviously I am doing something wrong... The dump contains three tables, <code>first_report</code>,<code>second_report</code> and <code>relation_table</code>.</p>

jawwe
<ol>
<li><p>you definitely  don't need to create empty tables in PostgreSQL, your dump file should contains <code>create table</code> statements. I'd recommend to test with dumping a schema only, without data <code>sqlite3 sqlite.db .schema &gt; dump.sql</code></p></li>
<li><p>In order to restore db from dump inside a container just run</p>

<p><code>kubectl exec -it postgres-pod -- psql --username admin --d testdb &lt; dump.sql</code></p></li>
</ol>

<p>If it won't help, please share you <strong>dump.sql</strong> file (schema only)</p>
