intri-in / manage-my-damn-life-nextjs

Manage My Damn Life (MMDL) is a self-hosted front end for managing your CalDAV tasks and calendars.
https://intri.in/manage-my-damn-life/
GNU General Public License v3.0
199 stars 8 forks source link

DB tables doesn't exist #128

Closed Knud3 closed 10 months ago

Knud3 commented 10 months ago

Should tables created automatically?

I installed MMDL using Docker Compose and these can be found from DB log:

2024-01-15 03:17:36+00:00 [Note] [Entrypoint]: Creating database sample_install_mmdm
2024-01-15 03:17:36+00:00 [Note] [Entrypoint]: Creating user myuser
2024-01-15 03:17:36+00:00 [Note] [Entrypoint]: Giving user myuser access to schema sample_install_mmdm

And these from MMDL itself:

Error: Table 'sample_install_mmdm.settings' doesn't exist
Error: Table 'sample_install_mmdm.users' doesn't exist

Do I need to create these manually?

intri-in commented 10 months ago

Can you visit http://localhost:3000/install/ and see if the tables have been installed?

Knud3 commented 10 months ago

Oh, I somehow missed that entirely.

When entering that page it gives Your database settings seem fine. You're all set for installation. in UI and it logs:

Executing (default): SHOW TABLES
[]
installed false

After I click Install in UI:

[object Object]
Something went wrong. Please try again later. Try checking logs for more details.

There were no log lines for this action.

Meanwhile DB is spamming these lines:

2024-01-15T10:18:51.938298Z 38 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
2024-01-15T10:18:51.948927Z 39 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
2024-01-15T10:18:51.959378Z 40 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
2024-01-15T10:19:01.796875Z 41 [Warning] [MY-013360] [Server] Plugin mysql_native_password reported: ''mysql_native_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'

But, those are only warnings for now.

intri-in commented 10 months ago

Hi, I think I have the issue figured out, and I will push the changes to this repo, as well as docker hub after I run a few tests.

I will update this issue as soon as fix is available -- at most in a day or two.

UI based installation won't work until I push a fix.

Meanwhile, if you want to try MMDL, you can:

Option 1: Run without Docker

Detailed instructions are here https://manage-my-damn-life-nextjs.readthedocs.io/en/latest/install/Dockerless/Install/

This will run database migrations manually, so you will get to skip the UI based installation.

Option 2:

Really convoluted way to make docker work.

  1. Setup your .env file, which you probably have since you are getting OK status connecting to database on the first screen.
  2. Run docker compose up so that your mysql container is running.
  3. In a separate window, go to the cloned repo.
  4. Run docker ps and get container id of mysql container for mmdl.
  5. Get the local IP address of your mysql container for mmdl docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ID_OF_YOUR_MMDL_MYSQL_CONTAINER
  6. Use this IP address as DB_HOST variable in your .env file.
  7. Run npm run migrate to run db migrations inside your docker mysql container.
Knud3 commented 10 months ago

How it would differ when changed hostname to IP address? I do not know about MySQL, but host will be generally found when hostname is used and containers are in same Docker network. Actually exposing port is also not needed if container is not used outside of Docker. It would only add attack vector.

Also there is no npm inside MySQL container:

npm --version
bash: npm: command not found
intri-in commented 10 months ago

Also there is no npm inside MySQL container:

the migrate script is in your MMDL container, so you will have to run npm run migrate inside that. The easiest option would be to just use it without Docker at the moment. Or wait for the fix, which will be pushed soon.

Run npm run migrate to run db migrations inside your docker mysql container.

I could have phrased that better.

Knud3 commented 10 months ago

Seems to be working now

/app # npm run migrate

> manage-my-damn-life-nextjs@0.4.3 migrate
> npx sequelize-cli db:migrate --env local

Sequelize CLI [Node: 18.16.0, CLI: 6.6.1, ORM: 6.32.1]

Loaded configuration file "config/config.js".
Using environment "local".
== 20230728075614-first_migration: migrating =======
== 20230728075614-first_migration: migrated (1.655s)

== 20230730083903-users-add-columns-nextAuth-v-0.3.0: migrating =======
== 20230730083903-users-add-columns-nextAuth-v-0.3.0: migrated (0.616s)

== 20230730093908-create-session: migrating =======
== 20230730093908-create-session: migrated (0.205s)

== 20230730094838-create-account: migrating =======
== 20230730094838-create-account: migrated (0.169s)
Knud3 commented 10 months ago

I hope you do not mind that I opened some propositions :)