cachethq / core

🚦 The core of Cachet, the open-source status page system.
https://cachethq.io
Other
159 stars 36 forks source link

General Error returned when running Migrations on 3.x with Sqlite #120

Open dakotawashok opened 1 month ago

dakotawashok commented 1 month ago

I think this error is because the migration didn't specify that this field can be nullable. Altering the line to $table->json('payload')->nullable()->after('locked'); allows the migrations to run successfully.

https://github.com/cachethq/core/blob/9372410620c76108a77813ba40b24e509dd9fa87/database/migrations/2024_01_22_202432_update_settings_table.php#L17

 2023_08_30_212242_make_incident_updates_columns_nullable ............................................................................ 42.45ms DONE
  2023_08_30_212242_make_metrics_columns_nullable ..................................................................................... 51.24ms DONE
  2023_09_18_105838_add_engine_column_to_incident_templates_table ...................................................................... 8.65ms DONE
  2024_01_22_202432_update_settings_table ............................................................................................. 18.04ms FAIL

   Illuminate\Database\QueryException 

  SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL (Connection: sqlite, SQL: alter table "settings" add column "payload" text not null)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:825
    821▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    822▕                 );
    823▕             }
    824▕
  ➜ 825▕             throw new QueryException(
    826▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    827▕             );
    828▕         }
    829▕     }

      +36 vendor frames 

  37  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))

➜  status_page git:(main) ✗
jbrooksuk commented 1 month ago

What database service are you using?

dakotawashok commented 1 month ago

Sorry, I'm not entirely sure. I believe it's just Sqlite with a database/database.sqlite file.

jbrooksuk commented 1 month ago

This migration is based off the spatie/laravel-settings migration — Cachet 3.x will migrate 2.x settings to the new format. https://github.com/spatie/laravel-settings/blob/main/database/migrations/create_settings_table.php.stub#L17

They don't have a nullable json field either... I wonder why that's failing for you. It doesn't happen when I run composer start...

jbrooksuk commented 1 month ago

@dakotawashok are you migrating a 2.x instance of Cachet or starting fresh?

dakotawashok commented 1 month ago

@jbrooksuk This is a new, fresh project using the 3.x branch as a base. Are you using sqlite when you run composer start to run the migrations, or another type of DB? In fact, I'm not able to run composer start at all, it gives me this error: image

jbrooksuk commented 1 month ago

@dakotawashok just to check, are you cloning the Core repository or Cachet? The start and dev commands are definitely there, https://github.com/cachethq/core/blob/5557a4124a8a060b01c587fe58b012c3484b371b/composer.json#L72-L79.

dakotawashok commented 1 month ago

@jbrooksuk I think I'm cloning the cachethq/cachet@3.x branch, is that not the right way to install? https://github.com/cachethq/cachet/blob/a3ca218f97c252276ba46a61d775e3122254431c/composer.json#L47

jbrooksuk commented 4 weeks ago

@dakotawashok yeah, cloning the 3.x branch is correct. Would you be open to emailing me, james [at] cachethq [dot] io and perhaps we could have a call to figure this out? I think it'd be easier!

dakotawashok commented 4 weeks ago

@jbrooksuk Absolutely, I'd be happy to!

jbrooksuk commented 4 weeks ago

Great! I look forward to it 😄

dakotawashok commented 3 weeks ago

I sent an email, lemme know if you got it 👍🏻

jbrooksuk commented 3 weeks ago

I didn't, sorry! Try james@alt-three.com instead please :)

dakotawashok commented 6 days ago

I sent an email to that one as well, but didn't get a response. I'm going to try again, but feel free to send me a message as well @jbrooksuk

jbrooksuk commented 3 days ago

@dakotawashok weird, I've not received any emails r.e. Cachet. Can you try sending to my alt-three.com again please?

dakotawashok commented 2 days ago

🫡 It's sent! Let me know if you get this one: image

dakotawashok commented 2 days ago

Also, we're getting this error when using regular pgsql as well, not just sqlite. We can go over how we install it/deploy it in email/chatting.