eddiesigner / liebling

Beautiful and clean Ghost theme that is easy and comfortable to use. To get the latest version please head over the releases page πŸ‘‰πŸΌ
https://github.com/eddiesigner/liebling/releases
MIT License
1.25k stars 597 forks source link

Local theme development: `Unable to run migrations` #464

Closed marnixhoh closed 2 years ago

marnixhoh commented 2 years ago

Hi,

I followed the instructions here: https://github.com/eddiesigner/liebling/wiki/Theme-development-with-Docker

But I get the following error:

[DOCKER] Attaching to ghost
[DOCKER] ghost    | [2022-08-12 09:39:59] INFO Ghost is running in development...
[DOCKER] ghost    | [2022-08-12 09:39:59] INFO Listening on: :::2368
[DOCKER] ghost    | [2022-08-12 09:39:59] INFO Url configured as: http://localhost:2368/
[DOCKER] ghost    | [2022-08-12 09:39:59] INFO Ctrl+C to shut down
[DOCKER] ghost    | [2022-08-12 09:39:59] INFO Ghost server started in 2.114s
[DOCKER] ghost    | [2022-08-12 09:40:00] WARN Database state requires migration.
[DOCKER] ghost    | [2022-08-12 09:40:01] INFO Creating database backup
[DOCKER] ghost    | [2022-08-12 09:40:01] INFO Database backup written to: /var/lib/ghost/content/data/liebling.ghost.2022-08-12-09-40-01.json
[DOCKER] ghost    | [2022-08-12 09:40:01] INFO Running migrations.
[DOCKER] ghost    | [2022-08-12 09:40:01] INFO Rolling back: Unable to run migrations.
[DOCKER] ghost    | [2022-08-12 09:40:01] INFO Rollback was successful.
[DOCKER] ghost    | [2022-08-12 09:40:01] ERROR Unable to run migrations
[DOCKER] ghost    | 
[DOCKER] ghost    | Unable to run migrations
[DOCKER] ghost    | 
[DOCKER] ghost    | "You must be on the latest v2.x to update across major versions - https://ghost.org/docs/update/"
[DOCKER] ghost    | "Run 'ghost update v2' to get the latest v2.x version, then run 'ghost update' to get to the latest."
[DOCKER] ghost    | 
[DOCKER] ghost    | Error ID:
[DOCKER] ghost    |     bc7b4980-1a22-11ed-91ea-3bed1453e266
[DOCKER] ghost    | 
[DOCKER] ghost    | ----------------------------------------
[DOCKER] ghost    | 
[DOCKER] ghost    | InternalServerError: Unable to run migrations
[DOCKER] ghost    |     at /var/lib/ghost/versions/5.2.3/node_modules/knex-migrator/lib/index.js:1032:19
[DOCKER] ghost    |     at up (/var/lib/ghost/versions/5.2.3/core/server/data/migrations/utils/migrations.js:118:19)
[DOCKER] ghost    |     at Object.up (/var/lib/ghost/versions/5.2.3/core/server/data/migrations/utils/migrations.js:54:19)
[DOCKER] ghost    |     at /var/lib/ghost/versions/5.2.3/node_modules/knex-migrator/lib/index.js:982:33
[DOCKER] ghost    |     at /var/lib/ghost/versions/5.2.3/node_modules/knex/lib/execution/transaction.js:221:22
[DOCKER] ghost    | 
[DOCKER] ghost    | [2022-08-12 09:40:01] WARN Ghost is shutting down
[DOCKER] ghost    | [2022-08-12 09:40:01] WARN Ghost has shut down
[DOCKER] ghost    | [2022-08-12 09:40:01] WARN Ghost was running for a few seconds
[DOCKER] ghost exited with code 2

Any help would be greatly appreciated. Also, please let me know if there is any more information I can provide :)

Thank you so much!

shincurry commented 2 years ago

workaround

docker-compose.yml

version: '3.1'

services:
  ghost:
    image: ghost:latest
    restart: always
    ports:
      - 127.0.0.1:2368:2368
    environment:
      NODE_ENV: development
      database__client: mysql
      database__connection__host: db
      database__connection__user: root
      database__connection__password: password
      database__connection__database: ghost_dev
    volumes:
      - ./..:/var/lib/ghost/content/themes/liebling
  db:
    image: mysql:8
    environment:
      MYSQL_ROOT_PASSWORD: password
    volumes:
      - ~/ghost_dev_data/mysql:/var/lib/mysql
      # ↑ anywhere except the project directory
marnixhoh commented 2 years ago

@shincurry Thank you for the suggestion. :)

Your workaround suggests to use MySQL. However, the local development instructions say to download the ghost.db database file, which is a sqlite file. Ideally, I'd like to use this db file.

I appreciate your response, but I hope that the maintainers or someone else can help me get the ghost.db file to work.

Thanks again

eddiesigner commented 2 years ago

This has been fixed in the latest version, I also updated the documentation to reflect the implemented changes.

I recommend you to remove the current container from the Docker dashboard so the next time you run docker-watch it starts fresh.

marnixhoh commented 2 years ago

@eddiesigner Awesome! Thank you so much for fixing this. I will give it a try later

Onihani commented 1 year ago

Hi @marnixhoh and @eddiesigner , I have tried it with the new update but it still doesn't seem to be using the ghost.db sqlite file

dschwertfeger commented 1 year ago

Hi @Onihani,

Looks like ghost is actually creating and using a sqlite database located at /var/lib/ghost/current/content/data/ghost-dev.db

To use your local ghost.db, which is mounted into the Docker container, specify it in docker-compose.yml

version: '3'

services:
  ghost:
    image: ghost:5.14.1
    container_name: ghost
    volumes:
      - ./..:/var/lib/ghost/content/themes/liebling:Z
      - ./ghost.db:/var/lib/ghost/content/data/ghost.db:Z
    environment:
      NODE_ENV: development
      database__client: sqlite3
      database__connection__filename: content/data/ghost.db
    ports:
      - 2368:2368

Read more about database configuration.

Onihani commented 1 year ago

@dschwertfeger thanks a lot it works now. This was really helpful. Thanks again πŸ™πŸΎπŸ™‡πŸΎ

marnixhoh commented 1 year ago

@Onihani I haven't tried the new update yet and I only just had time to look at your question, but I see that you've found a solution. Awesome! :)