umami-software / umami

Umami is a simple, fast, privacy-focused alternative to Google Analytics.
https://umami.is
MIT License
22.53k stars 4.2k forks source link

[Bug] Table for events doesn't exist in the Database #1568

Closed MiguelNdeCarvalho closed 2 years ago

MiguelNdeCarvalho commented 2 years ago

Hey,

I have been using v1.36.0 and today I upgrade to v1.38.0 and everything is working smooth, but when I try to go to Realtime I get this error:

yarn run v1.22.19                                                                                                                                                                      [28/373]
$ npm-run-all check-db update-tracker start-server                                                                                                                                             
$ node scripts/check-db.js                                                                                                                                                                     
✓ DATABASE_URL is defined.                                                                                                                                                                     
✓ Database connection successful.                                                                                                                                                              
✓ Database tables found.                                                                                                                                                                       
Prisma schema loaded from prisma/schema.prisma                                                                                                                                                 
Datasource "db": MySQL database "umami" at "mariadb:3306"                                                                                                                                      

3 migrations found in prisma/migrations                                                        

Database schema is up to date!                                                                                                                                                                 

✓ Database is up to date.                                                                      
$ node scripts/update-tracker.js                                                                                                                                                               
$ node server.js                                                                               
Listening on port 3000                                                                                                                                                                         
PrismaClientKnownRequestError:                                                                 
Invalid `prisma.event.findMany()` invocation:                                                  

The column `umami.event.event_name` does not exist in the current database.                    
    at RequestHandler.handleRequestError (/app/node_modules/@prisma/client/runtime/index.js:29909:13)                                                                                          
    at RequestHandler.request (/app/node_modules/@prisma/client/runtime/index.js:29892:12)     
    at async PrismaClient._request (/app/node_modules/@prisma/client/runtime/index.js:30864:16)                                                                                                
    at async Promise.all (index 2)             
    at async getRealtimeData (/app/.next/server/chunks/769.js:1618:43)                         
    at async __WEBPACK_DEFAULT_EXPORT__ (/app/.next/server/pages/api/realtime/init.js:158:22)
    at async Object.apiResolver (/app/node_modules/next/dist/server/api-utils/node.js:184:9)                                                                                                   
    at async NextNodeServer.runApi (/app/node_modules/next/dist/server/next-server.js:403:9)
    at async Object.fn (/app/node_modules/next/dist/server/base-server.js:493:37)
    at async Router.execute (/app/node_modules/next/dist/server/router.js:222:36) {
  code: 'P2022',
  clientVersion: '4.3.1',
  meta: { column: 'umami.event.event_name' }
}

I can see the problem is that the table is missing from my database, but I don't know which commands I should run for Prisma to create the missing table.

Thanks, MiguelNdeCarvalho

briancao commented 2 years ago

Weird that no errors came out of running your migration, while failing to create the table.

Can you do a select * from _prisma_migrations and show your results?

check-db runs prisma migrate deploy under the hood, and that should have either created the table, or shown an error.

Another heads up is that Umami now has a requirement of MariaDB 10.5.2+, so make sure your DB is of the correct version.

briancao commented 2 years ago

Closing due to no activity.

MiguelNdeCarvalho commented 2 years ago

Hey @briancao,

Sorry for the late response, is it possible for you to reopen the issue please? Right now I'm using MariaDB v10.6.10 so it shouldn't be a problem I think.

Here is the output for select * from _prisma_migrations:

id checksum finished_at migration_name logs rolled_back_at started_at applied_steps_count
6aeda5ca-5c8e-4ccb-97c4-ef34a1d9756e 66835af89beab3da653931fbe1de5e553aa87e3165190fdea6f9972f0391dbfe 2022-10-13 09:41:28.781 02_add_event_data 2022-10-13 09:41:28.781 0
e2688984-60c3-4283-be84-0f1c819a5057 78a595c5c6bf3a4d2d71a6e3d77618aa857b4df020794cbb975ba786bcdc37b5 2022-10-13 09:42:59.009 03_remove_cascade_delete 2022-10-13 09:42:59.009 0
f722364f-4394-4fd9-a39a-7f4b526b3819 d6765f3ae2a8b9d2d0730452f4f277a03b2cc1a968ba9b01d34041a958dc46c7 2022-06-28 14:03:59.676 01_init 2022-06-28 14:03:59.676 0

Thanks, MiguelNdeCarvalho