memos icon indicating copy to clipboard operation
memos copied to clipboard

Upgrade Docker Container loses memos

Open blaine07 opened this issue 2 years ago • 5 comments

Describe the bug

When I update the container all my memos are gone/lost.

What am I doing wrong?

Steps to reproduce

Update container and current memos are gone

Screenshots or additional context

No response

blaine07 avatar Nov 27 '22 23:11 blaine07

Just did update on my swarm, error: cannot open db: failed to find migration history, err: no such table: migration_history, had to manually create sqlite3 table:

CREATE TABLE migration_history (
   version TEXT NOT NULL PRIMARY KEY,
   created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now'))
 );

I didn't see any migrations running when updated the version and the login to system was not possible it threw some errors, after changelog investigation i saw that some sql schema have changed:

Email changed to Username

So i manually applied:

ALTER TABLE user RENAME TO _user_old;

-- user
CREATE TABLE user (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
  updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
  row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL',
  username TEXT NOT NULL UNIQUE,
  role TEXT NOT NULL CHECK (role IN ('HOST', 'ADMIN', 'USER')) DEFAULT 'USER',
  email TEXT NOT NULL DEFAULT '',
  nickname TEXT NOT NULL DEFAULT '',
  password_hash TEXT NOT NULL,
  open_id TEXT NOT NULL UNIQUE
);

INSERT INTO user (
  id, created_ts, updated_ts, row_status, 
  username, role, email, nickname, password_hash, 
  open_id
) 
SELECT 
  id, 
  created_ts, 
  updated_ts, 
  row_status, 
  email, 
  role, 
  email, 
  name, 
  password_hash, 
  open_id 
FROM 
  _user_old;

DROP TABLE IF EXISTS _user_old;

After that everything seems like fine!

e1z0 avatar Nov 27 '22 23:11 e1z0

Steps to reproduce

Update container and current memos are gone

Yeah, that really doesn't tell us anything about what you've done to update. What commands have you run? What did they output?

jxpsert avatar Nov 28 '22 00:11 jxpsert

Steps to reproduce

Update container and current memos are gone

Yeah, that really doesn't tell us anything about what you've done to update. What commands have you run? What did they output?

Updated the container in docker in unraid. No more, no less. Then container no longer contains my memos. Have storage path defined.

blaine07 avatar Nov 28 '22 00:11 blaine07

I have the same issue. Updated the docker with the following command: docker-compose down && docker image rm neosmemo/memos:latest && docker-compose up -d (as stated in the README). Container didn't start, so I did a docker-compose up (without the -d) and I got:

[+] Running 1/0
 ⠿ Container memos  Created                                                                                                                                                                                                                                              0.0s
Attaching to memos
memos  | ---
memos  | profile
memos  | mode: prod
memos  | port: 5230
memos  | dsn: /var/opt/memos/memos_prod.db
memos  | version: 0.8.0
memos  | ---
memos  | error: cannot open db: failed to find migration history, err: no such table: migration_history
memos exited with code 1

I use a docker-compose file where I defined a bind mount for /var/opt/memos. Used to work fine.

My docker-compose.yml:

services:
  memos:
    image: neosmemo/memos:latest
    container_name: memos
    volumes:
      - ./memos:/var/opt/memos
    ports:
      - 5230:5230

jeffrey-ose avatar Nov 30 '22 16:11 jeffrey-ose

I have the same issue. Updated the docker with the following command: docker-compose down && docker image rm neosmemo/memos:latest && docker-compose up -d (as stated in the README). Container didn't start, so I did a docker-compose up (without the -d) and I got:

[+] Running 1/0
 ⠿ Container memos  Created                                                                                                                                                                                                                                              0.0s
Attaching to memos
memos  | ---
memos  | profile
memos  | mode: prod
memos  | port: 5230
memos  | dsn: /var/opt/memos/memos_prod.db
memos  | version: 0.8.0
memos  | ---
memos  | error: cannot open db: failed to find migration history, err: no such table: migration_history
memos exited with code 1

I use a docker-compose file where I defined a bind mount for /var/opt/memos. Used to work fine.

My docker-compose.yml:

services:
  memos:
    image: neosmemo/memos:latest
    container_name: memos
    volumes:
      - ./memos:/var/opt/memos
    ports:
      - 5230:5230

I'm already posted a workaround for this :)

e1z0 avatar Nov 30 '22 16:11 e1z0