Database migration manually for memos #3108
Replies: 6 comments 1 reply
-
|
I think it's best to post about this in discussions page |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I suspect a a problem with a character on the dump. I will try to sort this out and post the solution if I found it, meanwhile if someone is willing to help you can :-) Have a nice sunday. |
Beta Was this translation helpful? Give feedback.
-
|
请问有没有SQLite to MySQL的教程或者工具可以一键转换? |
Beta Was this translation helpful? Give feedback.
-
|
follow this doc in Chinese |
Beta Was this translation helpful? Give feedback.
-
|
THANK YOU @wbchn, YOU SAVED ME. <3 |
Beta Was this translation helpful? Give feedback.
-
|
I manually migrated from SQLite3 to PostgreSQL. First, I started a new Memos instance connected to PostgreSQL and saved a few test memos. Then, using a web app called DbGate, I compared the schemas of SQLite3 and PostgreSQL. In the
So, I exported the data from the jq '
def fix:
if has("pinned") then .pinned = (.pinned == 1) else . end
| if has("payload") and (.payload | type) == "string"
then .payload |= fromjson
else .
end;
if type == "array" then
map(fix)
elif type == "object" then
fix
else
.
end
' input.json > output.jsonAfter that, I imported the converted file using DbGate. In my case, I didn’t use the After copying the necessary data, I started Memos and PostgreSQL and checked whether the memos were displayed correctly. At this point, when saving new memos, the auto-increment of the memo ID did not work correctly, so I set the counter to a value larger than the maximum existing ID in the -- Check the name of the sequence
SELECT pg_get_serial_sequence('memo', 'id');
-- Check the current value of the sequence
SELECT last_value FROM public.memo_id_seq;
-- Restart numbering from 794
SELECT setval('public.memo_id_seq', 794, false);Even with this roundabout method, the migration worked successfully. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Describe the solution you'd like
I'm glad to see memos support database now, very thanks to all the contributors
Here is my migration note about how to migrate sqlite to postgres database, I think it also works on mysql.
Type of feature
Documentation
Additional context
pre migration
backup sqlite file to local
step1. create database and then set memos enviornment
step2. memos startup
start memos, auto create table/schema in postgres db, after service start finish(the console show memos logo), stop memos now.
step3. truncate data in db(conflict with
server_setting)step4. install pgloader and load data to postgres
edit and save below to
sqlite.load, only load data to postgres:after that, run command, and make sure there is no error
Tips: if you met error like
ERROR Database error 23505: duplicate key value violates unique constraint "system_setting_pkey", please review step3.step5. restart memos service, it works now.
Beta Was this translation helpful? Give feedback.
All reactions