Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Undeployed database alterations found #3965

Closed
AbondonedScrawl opened this issue Sep 14, 2024 · 16 comments
Closed

[Bug] Undeployed database alterations found #3965

AbondonedScrawl opened this issue Sep 14, 2024 · 16 comments
Labels
๐Ÿ› Bug Something isn't working | ็ผบ้™ท

Comments

@AbondonedScrawl
Copy link

๐Ÿ“ฆ Environment

Docker

๐Ÿ“Œ Version

v1.17.3

๐Ÿ’ป Operating System

Ubuntu

๐ŸŒ Browser

Chrome, Safari

๐Ÿ› Bug Description

When using docker compose, logto throws this error and exits:

> cli
> logto db seed --swe
info Seeding skipped
npm notice
npm notice New patch version of npm available! 10.8.2 -> 10.8.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.3
npm notice To update run: npm install -g [email protected]
npm notice
> start
> cd packages/core && NODE_ENV=production node .
(node:44) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
cache    warn No Redis client initialized, skipping
pre      error Found undeployed database alterations, you must deploy them first by npm run alteration deploy command.
 See https://docs.logto.io/docs/references/using-cli/database-alteration for reference.
index    error Error while initializing app:
index    error Error: Undeployed database alterations found.
    at checkAlterationState (file:///etc/logto/packages/core/build/main-F72FFTZD.js:26444:9)
    at async Promise.all (index 0)
    at async checkPreconditions (file:///etc/logto/packages/core/build/main-F72FFTZD.js:26408:3)
    at async Promise.all (index 3)
    at async file:///etc/logto/packages/core/build/main-F72FFTZD.js:26480:3

This started happening during latest updates.

๐Ÿ“ท Recurrence Steps

No response

๐Ÿšฆ Expected Behavior

No response

๐Ÿ“ Additional Information

No response

@AbondonedScrawl AbondonedScrawl added the ๐Ÿ› Bug Something isn't working | ็ผบ้™ท label Sep 14, 2024
@lobehubbot
Copy link
Member

๐Ÿ‘€ @AbondonedScrawl

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.
้žๅธธๆ„Ÿ่ฐขๆ‚จๆไบค issueใ€‚ๆˆ‘ไปฌไผšๅฐฝๅฟซ่ฐƒๆŸฅๆญคไบ‹๏ผŒๅนถๅฐฝๅฟซๅ›žๅคๆ‚จใ€‚ ่ฏท็กฎไฟๆ‚จๅทฒ็ปๆไพ›ไบ†ๅฐฝๅฏ่ƒฝๅคš็š„่ƒŒๆ™ฏไฟกๆฏใ€‚

Copy link

dosubot bot commented Sep 14, 2024

To resolve the "undeployed database alterations" error in a Docker environment for Logto, follow these steps:

  1. Create Configuration Files:

    mkdir lobe-chat-db
    curl -fsSL https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/local/docker-compose.yml > docker-compose.yml
    curl -fsSL https://raw.githubusercontent.com/lobehub/lobe-chat/HEAD/docker-compose/local/.env.example > .env
  2. Start Services:

    docker compose up -d
  3. Configure Logto:

    • Open http://localhost:3002 to access the Logto WebUI and register an administrator account.
    • Create a Next.js (App Router) application and add the following configurations:
      • Redirect URI: http://localhost:3210/api/auth/callback/logto
      • Post sign-out redirect URI: http://localhost:3210/
    • Obtain the App ID and App secrets, and fill them into your .env file corresponding to LOGTO_CLIENT_ID and LOGTO_CLIENT_SECRET.
  4. Configure MinIO S3:

    • Open http://localhost:9001 to access the MinIO WebUI. The default admin account password is configured in .env.
    • Create a bucket that matches the MINIO_LOBE_BUCKET field in your .env file, which defaults to lobe.
    • Choose a custom policy, copy the following content, and paste it in (if you modified the bucket name, please find and replace accordingly):
      {
        "Statement": [
          {
            "Effect": "Allow",
            "Principal": {
              "AWS": ["*"]
            },
            "Action": ["s3:GetBucketLocation"],
            "Resource": ["arn:aws:s3:::lobe"]
          },
          {
            "Effect": "Allow",
            "Principal": {
              "AWS": ["*"]
            },
            "Action": ["s3:ListBucket"],
            "Resource": ["arn:aws:s3:::lobe"],
            "Condition": {
              "StringEquals": {
                "s3:prefix": ["files/*"]
              }
            }
          },
          {
            "Effect": "Allow",
            "Principal": {
              "AWS": ["*"]
            },
            "Action": ["s3:PutObject", "s3:DeleteObject", "s3:GetObject"],
            "Resource": ["arn:aws:s3:::lobe/files/**"]
          }
        ],
        "Version": "2012-10-17"
      }
    • Create a new access key, and fill the generated Access Key and Secret Key into your .env file under S3_ACCESS_KEY_ID and S3_SECRET_ACCESS_KEY.
  5. Restart LobeChat Service:

    docker compose up -d
  6. Check Logs for Successful Start:
    If you see the following logs in the container, it indicates that it has started successfully:

    [Database] Start to migration...
    โœ… database migration pass.
    -------------------------------------
      โ–ฒ Next.js 14.x.x
      - Local:        http://localhost:3210
      - Network:      http://0.0.0.0:3210
    
     โœ“ Starting...
     โœ“ Ready in 95ms
    

By following these steps, you should be able to deploy the necessary database alterations and resolve the error [1].

To continue talking to Dosu, mention @dosu.

@AbondonedScrawl
Copy link
Author

@dosu, any ideas?

Copy link

dosubot bot commented Sep 14, 2024

To resolve the "undeployed database alterations" error in a Docker environment for Logto, you can try the following steps:

  1. Check Docker Logs: First, check the Docker logs for the database container to identify any specific issues related to the database migrations.

    docker logs -f lobe-database
  2. Force Remove Database Container and Restart: If there are issues with the database schema, you can try to forcibly remove the database container and restart it. This will ensure that the database schema migration is executed properly.

    docker compose down  # Stop services
    sudo rm -rf ./data   # Remove mounted database data
    docker compose up -d # Restart

These steps should help resolve the "undeployed database alterations" error by ensuring that the database schema is correctly migrated and the database container is properly restarted [1].

To continue talking to Dosu, mention @dosu.

@AbondonedScrawl
Copy link
Author

lobe-database logs:

[Database] Start to migration...
โœ… database migration pass.
-------------------------------------
  โ–ฒ Next.js 14.2.8
  - Local:        http://localhost:3210
  - Network:      http://0.0.0.0:3210

 โœ“ Starting...
 โœ“ Ready in 56ms
LOGTO_CLIENT_ID will be removed in the future. Please set AUTH_LOGTO_ID instead.
LOGTO_CLIENT_SECRET will be removed in the future. Please set AUTH_LOGTO_SECRET instead.
LOGTO_ISSUER will be removed in the future. Please set AUTH_LOGTO_ISSUER instead.
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
LOGTO_CLIENT_ID will be removed in the future. Please set AUTH_LOGTO_ID instead.
LOGTO_CLIENT_SECRET will be removed in the future. Please set AUTH_LOGTO_SECRET instead.
LOGTO_ISSUER will be removed in the future. Please set AUTH_LOGTO_ISSUER instead.
LOGTO_CLIENT_ID will be removed in the future. Please set AUTH_LOGTO_ID instead.
LOGTO_CLIENT_SECRET will be removed in the future. Please set AUTH_LOGTO_SECRET instead.
LOGTO_ISSUER will be removed in the future. Please set AUTH_LOGTO_ISSUER instead.
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant
[auth][warn][env-url-basepath-redundant] Read more: https://warnings.authjs.dev#env-url-basepath-redundant

@dosu

Copy link

dosubot bot commented Sep 14, 2024

To resolve the repeated warnings about LOGTO_CLIENT_ID, LOGTO_CLIENT_SECRET, and LOGTO_ISSUER being deprecated, you need to update your environment variables to the new configuration. Additionally, to address the env-url-basepath-redundant warning, ensure that your NEXTAUTH_URL is correctly set.

Here is the updated configuration for your environment variables:

NEXT_AUTH_SECRET=<your_generated_secret>
NEXT_AUTH_SSO_PROVIDERS=logto
AUTH_LOGTO_ID=<your_client_id>
AUTH_LOGTO_SECRET=<your_client_secret>
AUTH_LOGTO_ISSUER=<your_logto_issuer_url>
NEXTAUTH_URL=https://lobe.example.com/api/auth

Make sure to replace <your_generated_secret>, <your_client_id>, <your_client_secret>, and <your_logto_issuer_url> with the actual values from your Logto application configuration. This should resolve the deprecation warnings and the env-url-basepath-redundant warning in the lobe-database logs [1][2].

To continue talking to Dosu, mention @dosu.

@AbondonedScrawl
Copy link
Author

@dosu

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


@dosu

Copy link

dosubot bot commented Sep 14, 2024

To resolve the repeated warnings about LOGTO_CLIENT_ID, LOGTO_CLIENT_SECRET, and LOGTO_ISSUER being deprecated, update your environment variables to the new configuration:

# Old environment variables (deprecated)
# LOGTO_CLIENT_ID=your_old_client_id
# LOGTO_CLIENT_SECRET=your_old_client_secret
# LOGTO_ISSUER=your_old_issuer

# New environment variables
AUTH_LOGTO_ID=your_new_client_id
AUTH_LOGTO_SECRET=your_new_client_secret
AUTH_LOGTO_ISSUER=your_new_issuer

Replace your_new_client_id, your_new_client_secret, and your_new_issuer with the actual values you are using [1].

For the env-url-basepath-redundant warning, ensure that your NEXTAUTH_URL is correctly set:

NEXTAUTH_URL=https://lobe.example.com/api/auth

This should resolve the deprecation warnings and the env-url-basepath-redundant warning in the logs [2].

To continue talking to Dosu, mention @dosu.

@SpeedupMaster
Copy link
Contributor

This is caused by the logto update, logto was updated to version 1.20.0 today. There are two solutions:

  1. Continue to use version v1.19.0
  2. Enter the logto container and run the following command to deploy the database changes:
    npm run alteration deploy

@arvinxx
Copy link
Contributor

arvinxx commented Sep 14, 2024

we will remove logto soon and the recommand the casdoor as our auth provider. stay tuned.

@Lovest20018
Copy link

ๅฎนๅ™จไธ่ƒฝๅฏๅŠจ๏ผŒๆฒกๅŠžๆณ•่ฟ็งป๏ผŒๅช่ƒฝๆ‹‰่€็‰ˆๆœฌๅ…ˆ็”จไบ†๏ผŒๆœŸๅพ…็”จcasdoorใ€‚

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


The container cannot be started and there is no way to migrate it. I can only pull the old version and use it first. I look forward to using casdoor.

@zhangleijun111
Copy link

Casdoor

็ญ‰ไฝ ไบ†ๅคง็ฅž๏ผŒlogto็”Ÿไบงๆžๅˆฐๅพˆ็—›่‹ฆ๏ผŒcasdoorๆ”ฏๆŒๅ†…็ฝ‘docker้ƒจ็ฝฒๅ˜›

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. ๐Ÿ‘ฏ๐Ÿ‘ญ๐Ÿป๐Ÿง‘โ€๐Ÿคโ€๐Ÿง‘๐Ÿ‘ซ๐Ÿง‘๐Ÿฟโ€๐Ÿคโ€๐Ÿง‘๐Ÿป๐Ÿ‘ฉ๐Ÿพโ€๐Ÿคโ€๐Ÿ‘จ๐Ÿฟ๐Ÿ‘ฌ๐Ÿฟ


Casdoor

Waiting for you, sir. Logto production is very painful. Does casdoor support intranet docker deployment?

@zhangleijun111
Copy link

2. npm run alteration deploy

ๆˆ‘่ฟ™ไธชๆŠฅ้”™่ฟ˜ๆœ‰็š„ๆ‹ฏๆ•‘ๅ˜›

[]
1726470656127
(url)

@lobehub lobehub locked and limited conversation to collaborators Sep 25, 2024
@arvinxx arvinxx converted this issue into discussion #4138 Sep 25, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
๐Ÿ› Bug Something isn't working | ็ผบ้™ท
Projects
Archived in project
Development

No branches or pull requests

6 participants