UNMS icon indicating copy to clipboard operation
UNMS copied to clipboard

UNMS 0.14.X not running migrations correctly

Open mschmidt291 opened this issue 5 years ago • 10 comments

So since Ubiquiti decided to force UCRM for UNMS to work, I'm currently updating our Kubernetes Helm Chart, so UNMS 0.14.X can be run. But with a clean Postgresql databse, UNMS and UCRM are complaining about missing tables.

UNMS: Checking CRM database schema version. relation "crm_db_version_view" does not exist Retrying in 10s

UCRM: ERROR: relation "_db_version" does not exist LINE 1: SELECT COALESCE(MAX(version), '0') FROM _db_version ^ {"message":"Waiting for migrations (20190711111648). Last successful migration version: .","channel":"database_migrations_ready.sh","datetime":"2019-08-01T08:43:26+0000","severity":"INFO","level":200}

So clearly UNMS seems to fail, because UCRM is unable to finish the migrations. Are there any steps to take, to get the _db_version relation?

mschmidt291 avatar Aug 01 '19 08:08 mschmidt291

Ok I seem to have fixed it. Actually on a fresh deployment, UCRM migrations are not kicked off...

I had to run this in ucrm container: ./scripts/migrate.sh

EDIT: Actually, I'm also using kubernetes (handmade yaml, not helm) and it seems that we forgot to add the command: make server_with_migrate to your pod

Without it, migrations are not kicked off

fculpo avatar Sep 01 '19 23:09 fculpo

@mschmidt291 I would be interested in contributing to the helm chart (and potentially allow it to target single node cluster without much ha, which is my use case)

fculpo avatar Sep 02 '19 21:09 fculpo

Hey @fculpo ! Thanks for your input. If you're interested, you can open a PR for our UNMS Helm-Chart at https://github.com/t3n/helm-charts adding your fix. The chart can already be used in a single node environment :)

mschmidt291 avatar Sep 03 '19 07:09 mschmidt291

@fculpo I just tried it and updated the Helm Chart. Unfortunately, UNMS ist still complaining, that crm_db_version_view is not existing...

mschmidt291 avatar Sep 03 '19 11:09 mschmidt291

Please paste the ucrm startup logs, there should be the migration running

fculpo avatar Sep 03 '19 11:09 fculpo

To be certain, the make server_with_migrate command must go in the the ucrm container

Also if you applied fixes in my now deleted posts, you should delete the _db_version view from db before restarting ucrm

fculpo avatar Sep 03 '19 11:09 fculpo

The UCRM start should look like this:

/usr/src/ucrm/scripts/init_log.sh
/usr/src/ucrm/scripts/dirs.sh
{"message":"Creating directories.","channel":"dirs.sh","datetime":"2019-09-03T12:55:29+0000","severity":"INFO","level":200}
{"message":"Done creating directories.","channel":"dirs.sh","datetime":"2019-09-03T12:55:29+0000","severity":"INFO","level":200}
{"message":"Creating symbolic links.","channel":"dirs.sh","datetime":"2019-09-03T12:55:29+0000","severity":"INFO","level":200}
{"message":"Creating symbolic link for /usr/src/ucrm/app/data.","channel":"dirs.sh","datetime":"2019-09-03T12:55:29+0000","severity":"INFO","level":200}
{"message":"Creating symbolic link for /usr/src/ucrm/app/EmailQueue.","channel":"dirs.sh","datetime":"2019-09-03T12:55:30+0000","severity":"INFO","level":200}
{"message":"Creating symbolic link for /usr/src/ucrm/app/logs.","channel":"dirs.sh","datetime":"2019-09-03T12:55:30+0000","severity":"INFO","level":200}
{"message":"Creating symbolic link for /usr/src/ucrm/web/uploads.","channel":"dirs.sh","datetime":"2019-09-03T12:55:30+0000","severity":"INFO","level":200}
{"message":"Creating symbolic links for /data/updates.","channel":"dirs.sh","datetime":"2019-09-03T12:55:30+0000","severity":"INFO","level":200}
{"message":"Publishing current /usr/src/ucrm/app/config/version.yml.","channel":"dirs.sh","datetime":"2019-09-03T12:55:31+0000","severity":"INFO","level":200}
{"message":"Done creating symbolic links.","channel":"dirs.sh","datetime":"2019-09-03T12:55:31+0000","severity":"INFO","level":200}
/usr/src/ucrm/scripts/parameters.sh
{"message":"Replacing configuration parameters.","channel":"parameters.sh","datetime":"2019-09-03T12:55:31+0000","severity":"INFO","level":200}
{"message":"Done replacing configuration parameters.","channel":"parameters.sh","datetime":"2019-09-03T12:55:51+0000","severity":"INFO","level":200}
/usr/src/ucrm/scripts/cron_jobs_disable.sh
crontab /tmp/crontabs/server
su-exec nginx /usr/src/ucrm/scripts/database_ready.sh
{"message":"Waiting for database.","channel":"database_ready.sh","datetime":"2019-09-03T12:55:51+0000","severity":"INFO","level":200}
{"message":"Database ready.","channel":"database_ready.sh","datetime":"2019-09-03T12:55:51+0000","severity":"INFO","level":200}
su-exec nginx /usr/src/ucrm/scripts/migrate.sh
{"message":"Start database migration.","channel":"migrate.sh","datetime":"2019-09-03T12:55:52+0000","severity":"INFO","level":200}
{"message":"Done database migration.","channel":"migrate.sh","datetime":"2019-09-03T12:55:54+0000","severity":"INFO","level":200}
{"message":"Start shared views migration.","channel":"migrate.sh","datetime":"2019-09-03T12:55:54+0000","severity":"INFO","level":200}
{"message":"Done shared views migration.","channel":"migrate.sh","datetime":"2019-09-03T12:55:56+0000","severity":"INFO","level":200}
{"message":"Start notification templates migration.","channel":"migrate.sh","datetime":"2019-09-03T12:55:56+0000","severity":"INFO","level":200}
{"message":"Done notification templates migration.","channel":"migrate.sh","datetime":"2019-09-03T12:55:58+0000","severity":"INFO","level":200}
{"message":"Bumping UNMS version from ENV variable to database.","channel":"migrate.sh","datetime":"2019-09-03T12:55:58+0000","severity":"INFO","level":200}
{"message":"Done bumping UNMS version from ENV variable to database.","channel":"migrate.sh","datetime":"2019-09-03T12:55:59+0000","severity":"INFO","level":200}
su-exec nginx /usr/src/ucrm/scripts/database_migrations_ready.sh
{"message":"Waiting for migrations.","channel":"database_migrations_ready.sh","datetime":"2019-09-03T12:55:59+0000","severity":"INFO","level":200}
{"message":"Migrations ready.","channel":"database_migrations_ready.sh","datetime":"2019-09-03T12:56:00+0000","severity":"INFO","level":200}
/usr/src/ucrm/scripts/web.sh
{"message":"Preparing server configuration.","channel":"web.sh","datetime":"2019-09-03T12:56:00+0000","severity":"INFO","level":200}
{"message":"Done preparing server configuration.","channel":"web.sh","datetime":"2019-09-03T12:56:00+0000","severity":"INFO","level":200}
{"message":"Updating environment variables.","channel":"web.sh","datetime":"2019-09-03T12:56:01+0000","severity":"INFO","level":200}
{"message":"Done updating environment variables.","channel":"web.sh","datetime":"2019-09-03T12:56:02+0000","severity":"INFO","level":200}
{"message":"Updating UCRM version.","channel":"web.sh","datetime":"2019-09-03T12:56:02+0000","severity":"INFO","level":200}
{"message":"Done UCRM version.","channel":"web.sh","datetime":"2019-09-03T12:56:03+0000","severity":"INFO","level":200}

fculpo avatar Sep 03 '19 13:09 fculpo

@fculpo When running the server_with_migrate makefile, it just throws:

                                                                                      
  An exception occurred while executing 'DROP VIEW IF EXISTS public.crm_option_view;  
  CREATE VIEW public.crm_option_view AS                                               
      SELECT                                                                          
          g.code::text,                                                               
          g.value::text                                                               
      FROM ucrm.general g                                                             
      WHERE g.code IN (                                                               
          'wizard_done',                                                              
          'unms_version'                                                              
      )                                                                               
  ;                                                                                   
  ':                                                                                  
                                                                                      
  SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "ucrm.general" does not exist  
  LINE 6:     FROM ucrm.general g                                                     
                   ^                                                                  
                                                                                      

In PDOConnection.php line 43:
                                                                                      
  SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "ucrm.general" does not exist  
  LINE 6:     FROM ucrm.general g                                                     
                   ^                                                                  
                                                                                      

In PDOConnection.php line 41:
                                                                                      
  SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "ucrm.general" does not exist  
  LINE 6:     FROM ucrm.general g                                                     
                   ^

at {"message":"Start shared views migration.","channel":"migrate.sh","datetime":"2019-09-04T07:25:35+0000","severity":"INFO","level":200}

mschmidt291 avatar Sep 04 '19 07:09 mschmidt291

Could you try with a clean db ? Also my issue was officially on v1.0.1 (but seems pretty similar as 0.14.x)

What happens if you manually run the migrate.sg script inside the container ?

fculpo avatar Sep 04 '19 08:09 fculpo

Hello @mschmidt291. Please let me know what command did you use to install UNMS, I am mostly interested in all those optional parameters. What was the outcome of installation (I guess it was installed without errors right?), and I will need your current UNMS support info. Please, send those files to the email radek.skrivan(at)ubnt.com, and include your forum name and URL of this thread in the message. In case the files are too big, please use a file sharing service such as Google Drive.

radekskrivan avatar Sep 06 '19 12:09 radekskrivan