Tables user and userPasswords showing errors
Issue Summary
I can't login into my selfhosted instance, always says unknown user.
Checked in Studio the table user and userPassword and get the following errors:
- UserPassword:
The table
public.UserPassworddoes not exist in the current database. - User
The column
users.appThemedoes not exist in the current database
Was there an migration in one of the last versions? I am running watchtower to do the updates. Can I somehow run a script, that the tables are added?
Thanks
It looks like your database is missing some updates, likely due to a migration issue. Here's how to fix it:
- Add the
appThemecolumn to theUsertable:
ALTER TABLE "users" ADD COLUMN "appTheme" TEXT;
- Create the
UserPasswordtable:
CREATE TABLE "UserPassword" (
"hash" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
PRIMARY KEY ("userId")
);
CREATE UNIQUE INDEX "UserPassword_userId_key" ON "UserPassword" ("userId");
ALTER TABLE "UserPassword" ADD CONSTRAINT "UserPassword_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
INSERT INTO "UserPassword" ("hash", "userId")
SELECT u."password", u.id FROM users u WHERE u."password" IS NOT NULL;
These steps address the missing UserPassword table and the appTheme column in the User table. After running these SQL commands, your database should be aligned with the expected schema, resolving the login issue.
Details
Sources
- packages/prisma/migrations/20231201233433_add_new_user_field_app_theme/migration.sql
- packages/prisma/migrations/20240209223121_adds_user_password/migration.sql
- apps/web/pages/settings/my-account/appearance.tsx
- packages/core/package.json
- apps/web/lib/orgMigration.test.ts
- .env.example
About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
Thanks, now I can login but get the following error in the logs of my database ERROR: column DestinationCalendar.primaryEmail
Could I get as well the migration script for DestinationCalendar.primaryEmail? #
Thanks
To add the primaryEmail column to the DestinationCalendar table, you can use the following SQL script:
ALTER TABLE "DestinationCalendar" ADD COLUMN "primaryEmail" TEXT;
This script will create the primaryEmail column in your DestinationCalendar table, which is necessary for storing the primary email addresses associated with destination calendars. Execute this script in your database to resolve the error you're encountering.
If there are any further adjustments or assistance you need, feel free to ask.
Details
Sources
- packages/prisma/migrations/20231220152005_add_email_in_destination_calendar/migration.sql
- packages/prisma/schema.prisma
- packages/lib/getConnectedDestinationCalendars.ts
- packages/prisma/migrations/20211207010154_add_destination_calendar/migration.sql
- packages/prisma/migrations/20220629151617_connect_destination_calendar_to_credential/migration.sql
About Dosu This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
To continue the conversation, mention @dosu.
Thanks a lot, somehow a lot of scripts were not executed. I did it now manually from the migrations folder from github