mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Documentation: Remove SQLite to Postgres in favor of export/import (#6401)
This commit is contained in:
parent
21c7675f66
commit
ea8127202d
@ -691,95 +691,8 @@ commands as well.
|
||||
|
||||
## Moving data from SQLite to PostgreSQL or MySQL/MariaDB {#sqlite_to_psql}
|
||||
|
||||
Moving your data from SQLite to PostgreSQL or MySQL/MariaDB is done via
|
||||
executing a series of django management commands as below. The commands
|
||||
below use PostgreSQL, but are applicable to MySQL/MariaDB with the
|
||||
|
||||
!!! warning
|
||||
|
||||
Make sure that your SQLite database is migrated to the latest version.
|
||||
Starting paperless will make sure that this is the case. If your try to
|
||||
load data from an old database schema in SQLite into a newer database
|
||||
schema in PostgreSQL, you will run into trouble.
|
||||
|
||||
!!! warning
|
||||
|
||||
On some database fields, PostgreSQL enforces predefined limits on
|
||||
maximum length, whereas SQLite does not. The fields in question are the
|
||||
title of documents (128 characters), names of document types, tags and
|
||||
correspondents (128 characters), and filenames (1024 characters). If you
|
||||
have data in these fields that surpasses these limits, migration to
|
||||
PostgreSQL is not possible and will fail with an error.
|
||||
|
||||
!!! warning
|
||||
|
||||
MySQL is case insensitive by default, treating values like "Name" and
|
||||
"NAME" as identical. See [MySQL caveats](advanced_usage.md#mysql-caveats) for details.
|
||||
|
||||
!!! warning
|
||||
|
||||
MySQL also enforces limits on maximum lengths, but does so differently than
|
||||
PostgreSQL. It may not be possible to migrate to MySQL due to this.
|
||||
|
||||
!!! warning
|
||||
|
||||
Using mariadb version 10.4+ is recommended. Using the `utf8mb3` character set on
|
||||
an older system may fix issues that can arise while setting up Paperless-ngx but
|
||||
`utf8mb3` can cause issues with consumption (where `utf8mb4` does not).
|
||||
|
||||
1. Stop paperless, if it is running.
|
||||
|
||||
2. Tell paperless to use PostgreSQL:
|
||||
|
||||
a) With docker, copy the provided `docker-compose.postgres.yml`
|
||||
file to `docker-compose.yml`. Remember to adjust the consumption
|
||||
directory, if necessary.
|
||||
b) Without docker, configure the database in your `paperless.conf`
|
||||
file. See [configuration](configuration.md) for
|
||||
details.
|
||||
|
||||
3. Open a shell and initialize the database:
|
||||
|
||||
a) With docker, run the following command to open a shell within
|
||||
the paperless container:
|
||||
|
||||
``` shell-session
|
||||
$ cd /path/to/paperless
|
||||
$ docker compose run --rm webserver /bin/bash
|
||||
```
|
||||
|
||||
This will launch the container and initialize the PostgreSQL
|
||||
database.
|
||||
|
||||
b) Without docker, remember to activate any virtual environment,
|
||||
switch to the `src` directory and create the database schema:
|
||||
|
||||
``` shell-session
|
||||
$ cd /path/to/paperless/src
|
||||
$ python3 manage.py migrate
|
||||
```
|
||||
|
||||
This will not copy any data yet.
|
||||
|
||||
4. Dump your data from SQLite:
|
||||
|
||||
```shell-session
|
||||
$ python3 manage.py dumpdata --database=sqlite --exclude=contenttypes --exclude=auth.Permission > data.json
|
||||
```
|
||||
|
||||
5. Load your data into PostgreSQL:
|
||||
|
||||
```shell-session
|
||||
$ python3 manage.py loaddata data.json
|
||||
```
|
||||
|
||||
6. If operating inside Docker, you may exit the shell now.
|
||||
|
||||
```shell-session
|
||||
$ exit
|
||||
```
|
||||
|
||||
7. Start paperless.
|
||||
The best way to migrate between database types is to perform an [export](administration.md#exporter) and then
|
||||
[import](administration.md#importer) into a clean installation of Paperless-ngx.
|
||||
|
||||
## Moving back to Paperless
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user