# Some tables are already present in the database,

**URL:** https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919
**Category:** Installation Issues
**Created:** [July 17, 2020, 10:43am UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919 "2020-07-17T10:43:31Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 10:43am UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/1 "2020-07-17T10:43:31Z")

</div>

**Checklist**  
[] I have read intro post: [About the Installation Issues category](https://community.passbolt.com/t/about-the-installation-issues-category/12)  
[] I have read the tutorials, help and searched for similar issues  
[] I provide relevant information about my server (component names and versions, etc.)  
[] I provide a copy of my logs and healthcheck  
[] I describe the steps I have taken to trouble shoot the problem  
[] I describe the steps on how to reproduce the issue

I am trying to move my docker to another server…  
I am using Docker-compose  
i get this problem the make passbolt doesn’t start:

passbolt\_1 | Some tables are already present in the database, a new installation would override existing data.  
passbolt\_1 | Please use --force to proceed anyway.

passbolt\_1 | PDOException: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘folders’ already exists in /var/www/passbolt/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:184  
passbolt\_1 | Stack trace:

How can I fix that:

I have moved the docker folder to the new server. I have moved the certification.  
docker-compose up -d  
69a10fdf8d04 passbolt/passbolt:latest-pro “docker-php-entrypoi…” 9 minutes ago Exited (1) 6 minutes ago passbolt\_docker\_passbolt\_1  
e0bf6cd29adc mariadb:10.3 “docker-entrypoint.s…” 9 minutes ago Up 6 minutes 127.0.0.1:3306-\>3306/tcp passbolt\_docker\_db\_1

although passbolt doesn’t start i restored the database.  
but the issue is  
passbolt\_1 | == 20191119092944 V2130AddFoldersTable: migrating  
passbolt\_1 | PDOException: SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘folders’ already exists in /var/www/passbolt/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php:184  
passbolt\_1 | Stack trace:

---

<div class="post-metadata">

### Author: ![remy](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/remy/32/17_2.png) [@remy](https://community.passbolt.com/u/remy)
#### Post date: [July 17, 2020, 10:46am UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/2 "2020-07-17T10:46:20Z")

</div>

@Ahmad hello, seems like you are using passbolt pro, you should get in touch with [support@passbolt.com](mailto:support@passbolt.com) for help.

“Table are already present” error generally appears when you have a mix match between passbolt versions (software, database content, database structure). For example this can happen when you reloaded content from a previous versions from backups in a database schema that was already migrated.

Long story short, you have the database structure of a new version, but you miss some of the content (such as which migration have been run). These issues are hard to fix as you need to manually match the structure and recreate database migrations table content.

Another way to fix this is to export the data that you have, check what is the highest migration version number in the phinx table (which list the migrations), and install this older version of passbolt, run the initial migration, load the data. Then you can upgrade again to the latest version.

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 11:14am UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/3 "2020-07-17T11:14:13Z")

</div>

That seems right  
my old version is 2.12.1 and now without meaning I have 2.13.1

Can you help me with downgrading?  
1- docker-compose down  
then I change in docker-compose-pro.yml  
from  
image: passbolt/passbolt:latest-pro  
to  
image: passbolt/passbolt:2.12.1  
2- then docker-compose up  
Is that right?

---

<div class="post-metadata">

### Author: ![remy](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/remy/32/17_2.png) [@remy](https://community.passbolt.com/u/remy)
#### Post date: [July 17, 2020, 11:32am UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/4 "2020-07-17T11:32:45Z")

</div>

@Ahmad in your scenario the best would actually to just edit the database manually and drop the following tables:

- folders
- folders\_history
- folders\_relations
- folders\_relations\_history

From there you should be able to finish the migrations again.

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 11:53am UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/5 "2020-07-17T11:53:16Z")

</div>

Hi.

I did that and that worked… THANKS  
I did that in a new server. I am really afraid to do that in the production server. Is that safe to drop those tables. will I lose any information?

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 11:54am UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/6 "2020-07-17T11:54:21Z")

</div>

Can yo help me with the upgrading procedure from 2.12.1  
and downgrading from 2.13.1 to 2.12.1

---

<div class="post-metadata">

### Author: ![remy](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/remy/32/17_2.png) [@remy](https://community.passbolt.com/u/remy)
#### Post date: [July 17, 2020, 12:06pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/7 "2020-07-17T12:06:22Z")

</div>

> [@Ahmad](#):
>
> Can yo help me with the upgrading procedure from 2.12.1  
> and downgrading from 2.13.1 to 2.12.1

It’s not sufficient to downgrade the code, you need both the code from v2.12.1 and database structure from v2.12.1. We don’t have official instruction to downgrade, it depends on your case (e.g where is your database, etc.). Basically the process is take your v2.12 backup and install a v2.12 software on a clean DB, load your v2.12 backup data.

> [@Ahmad](#):
>
> I did that in a new server. I am really afraid to do that in the production server. Is that safe to drop those tables. will I lose any information?

It’s hard to tell. Most likely you will only loose “Folders” information if at some point you were running v2.13.1 in production. Maybe you will have some other data issues if you were running previous version of the software against new database schema version. Or a mix of both depending on what you did. The best is load your production data into a staging environment, try it, see if it works.

To be honest it’s hard to advise without knowing which operations you did and in which order. I would need to know which version of the software you ran against which version of the database structure, and when was data loaded from v2.12 backup, then look at the log to check what users did during that time, etc.

Database structure, data and software version are meant to be in sync and are not always backward/forward compatible, as you experienced. You can always run the data cleanup tool afterwards to check for consistency issue:

```auto
./bin/cake passbolt cleanup --dry-run

```

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 12:12pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/8 "2020-07-17T12:12:35Z")

</div>

Database structure, data and software version are meant to be in sync

Can you please check if I have the right docker-compose-pro.yml  
version: ‘3.4’  
services:  
db:  
image: mariadb:10.3  
env\_file:  
- env/mysql.env  
volumes:  
- database\_volume:/var/lib/mysql  
ports:  
- “127.0.0.1:3306:3306”

passbolt:  
image: passbolt/passbolt:latest-pro  
#image: passboltlocal  
tty: true  
depends\_on:  
- db  
env\_file:  
- env/passbolt.env  
volumes:  
- gpg\_volume:/var/www/passbolt/config/gpg  
- images\_volume:/var/www/passbolt/webroot/img/public  
- ./license:/var/www/passbolt/config/license  
- /home/certs:/etc/ssl/certs/  
tmpfs:  
- /run  
command: ["/usr/bin/wait-for.sh", “db:3306”, “–”, “/docker-entrypoint.sh”]  
ports:  
- 127.0.0.1:80:80  
- 127.0.0.1:443:443

volumes:  
database\_volume:  
gpg\_volume:  
images\_volume:  
certs:

---

<div class="post-metadata">

### Author: ![kevin](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/kevin/32/128_2.png) [@kevin](https://community.passbolt.com/u/kevin)
#### Post date: [July 17, 2020, 12:32pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/9 "2020-07-17T12:32:36Z")

</div>

Your docker-compose file looks ok, but it is difficult to say for sure.

Can you run the following query on your database and let us know the output?

```auto
SELECT * FROM phinxlog;

```

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 12:44pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/10 "2020-07-17T12:44:56Z")

</div>

In the production server: not updated to 2.13 yet

20190106170300 | V280AdditionalEmailMigration | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190106170301 | V280AdditionalFileStorageMigration | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190106170302 | V280FileDirectoryPathsMigrations | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190112124290 | V270AddActionsTable | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190112124300 | V270AddActionLogsTable | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190121111100 | V270AddEntitiesHistoryTable | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190121121100 | V270AddPermissionsHistoryTable | 2020-04-21 14:36:18 | 2020-04-21 14:36:19 | 0 |  
| 20190211124300 | V270AddSecretsHistoryTable | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190221124300 | V270AddSecretAccessesTable | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190327142000 | V280AddTagsIndexesMigrations | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190512115400 | V2100AddOrganizationSettingsTable | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190623143400 | V2110ExtendKeyIdSizeField | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190923103000 | V2120UpdateEmailQueue | 2020-04-21 14:36:19 | 2020-04-21 14:36:29 | 0 |  
| 20191119160000 | V2120DropUnusedTables | 2020-04-21 14:36:29 | 2020-04-21 14:36:29 | 0 |  
±---------------±---------------------------------------±--------------------±--------------------±-----------+

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 12:46pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/11 "2020-07-17T12:46:17Z")

</div>

in the test server:  
updated to 2.13.1 , I don’t know how the updating just done.

20190106170301 | V280AdditionalFileStorageMigration | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190106170302 | V280FileDirectoryPathsMigrations | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190112124290 | V270AddActionsTable | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190112124300 | V270AddActionLogsTable | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190121111100 | V270AddEntitiesHistoryTable | 2020-04-21 14:36:18 | 2020-04-21 14:36:18 | 0 |  
| 20190121121100 | V270AddPermissionsHistoryTable | 2020-04-21 14:36:18 | 2020-04-21 14:36:19 | 0 |  
| 20190211124300 | V270AddSecretsHistoryTable | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190221124300 | V270AddSecretAccessesTable | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190327142000 | V280AddTagsIndexesMigrations | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190512115400 | V2100AddOrganizationSettingsTable | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190623143400 | V2110ExtendKeyIdSizeField | 2020-04-21 14:36:19 | 2020-04-21 14:36:19 | 0 |  
| 20190923103000 | V2120UpdateEmailQueue | 2020-04-21 14:36:19 | 2020-04-21 14:36:29 | 0 |  
| 20191119092944 | V2130AddFoldersTable | 2020-07-17 12:20:06 | 2020-07-17 12:20:06 | 0 |  
| 20191119092945 | V2130AddFoldersHistoryTable | 2020-07-17 12:20:06 | 2020-07-17 12:20:06 | 0 |  
| 20191119160000 | V2120DropUnusedTables | 2020-04-21 14:36:29 | 2020-04-21 14:36:29 | 0 |  
| 20191216092944 | V2130AddFoldersRelationsTable | 2020-07-17 12:20:06 | 2020-07-17 12:20:06 | 0 |  
| 20191216092945 | V2130AddFoldersRelationsHistoryTable | 2020-07-17 12:20:06 | 2020-07-17 12:20:06 | 0 |  
| 20200108135000 | V2130DropLegacyAnonymousUser | 2020-07-17 12:20:06 | 2020-07-17 12:20:06 | 0 |  
| 20200205135000 | V2130AddResourcesFoldersRelations | 2020-07-17 12:20:06 | 2020-07-17 12:20:07 | 0 |  
| 20200319135000 | V2130SoftDeleteGpgKeysForSoftDeletedUsers | 2020-07-17 12:20:07 | 2020-07-17 12:20:07 | 0 |  
| 20200609192000 | V2130AddMissingFoldersIndexes | 2020-07-17 12:20:07 | 2020-07-17 12:20:07 | 0 |  
±---------------±------------------------------------------±--------------------±--------------------±-----------+

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 12:46pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/12 "2020-07-17T12:46:53Z")

</div>

I still need the updating procedures from 2,12,1 to 2.12.3

---

<div class="post-metadata">

### Author: ![remy](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/remy/32/17_2.png) [@remy](https://community.passbolt.com/u/remy)
#### Post date: [July 17, 2020, 12:52pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/13 "2020-07-17T12:52:26Z")

</div>

> [@Ahmad](#):
>
> 2.12.3

I guess you mean 2.13. Ok, so the error you posted at the top, is it coming from your production server? Or was it from your test server?

Can you on your _ **production** _ server check:

```auto
show tables;

```

If you have any “folders” table can you do:

```auto
select count(id) from folders;

```

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 12:56pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/14 "2020-07-17T12:56:47Z")

</div>

±-----------------------------------+  
| Tables\_in\_passbolt |  
±-----------------------------------+  
| account\_settings |  
| action\_logs |  
| actions |  
| authentication\_tokens |  
| comments |  
| directory\_entries |  
| directory\_ignore |  
| directory\_relations |  
| directory\_reports |  
| directory\_reports\_items |  
| email\_queue |  
| entities\_history |  
| favorites |  
| file\_storage |  
| gpgkeys |  
| groups |  
| groups\_users |  
| organization\_settings |  
| passbolt\_account\_settings\_phinxlog |  
| passbolt\_directory\_sync\_phinxlog |  
| passbolt\_tags\_phinxlog |  
| permissions |  
| permissions\_history |  
| phinxlog |  
| profiles |  
| resources |  
| resources\_tags |  
| roles |  
| secret\_accesses |  
| secrets |  
| secrets\_history |  
| tags |  
| user\_agents |  
| users |  
±--------

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 12:57pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/15 "2020-07-17T12:57:10Z")

</div>

ERROR 1146 (42S02): Table ‘passbolt.folders’ doesn’t exist

---

<div class="post-metadata">

### Author: ![remy](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/remy/32/17_2.png) [@remy](https://community.passbolt.com/u/remy)
#### Post date: [July 17, 2020, 12:58pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/16 "2020-07-17T12:58:47Z")

</div>

@Ahmad from the look of it you should be able to upgrade the production database without the issue you faced on your test server, since the schema in your test environment and production were not the same.

If you want to be sure, pick up the database data and structure from the production database, load it in your test server and run the migration.

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 1:02pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/17 "2020-07-17T13:02:04Z")

</div>

If I take backup now from production and restore it to the test, then docker-compose restart. I get the same problem that about table folders…

I need the steps to upgrade the production docker…

---

<div class="post-metadata">

### Author: ![remy](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/remy/32/17_2.png) [@remy](https://community.passbolt.com/u/remy)
#### Post date: [July 17, 2020, 1:04pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/18 "2020-07-17T13:04:03Z")

</div>

> [@Ahmad](#):
>
> If I take backup now from production and restore it to the test, then docker-compose restart. I get the same problem that about table folders…

This is because you are loading the data in an already migrated schema. You need to make a backup of both the schema (create tables statements) and the data (insert statements). You need to load this in a clean test database without any tables (drop the tables first). From there you will be able to have the same database (schema and data) that your production environment, and test that the migration works as intended.

---

<div class="post-metadata">

### Author: ![Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/a4c791/32.png) [@Ahmad](https://community.passbolt.com/u/Ahmad)
#### Post date: [July 17, 2020, 1:11pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/19 "2020-07-17T13:11:57Z")

</div>

I don’t know exactly how to do that… I just take backup via mysqldump and the restore it… 🙂  
If you can help with more details about: make a backup of both the schema (create tables statements) and the data (insert statements). You need to load this in a clean test database without any tables (drop the tables first).  
I would be very thankful…

---

<div class="post-metadata">

### Author: ![remy](https://yyz1.discourse-cdn.com/flex031/user_avatar/community.passbolt.com/remy/32/17_2.png) [@remy](https://community.passbolt.com/u/remy)
#### Post date: [July 17, 2020, 1:31pm UTC](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919/20 "2020-07-17T13:31:47Z")

</div>

@Ahmad ok I understand your problem. Basically when you do a mysqldump it will contain the schema and data and do a “drop table if exist”, but it will not drop tables that are “not there” in the mysqldump but already in your test database. So it will only drop tables that are in production, not more.

So the easiest is just to cleanup your test database completely prior to loading your data from your production mysqldump, so something like:

```auto
drop database passbolt_test;
create database passbolt_test COLLATE utf8mb4_unicode_ci;

```

And then only you load your data from the dump.

[Next page](https://community.passbolt.com/t/some-tables-are-already-present-in-the-database/2919.md?page=2)
