cachethq / core

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

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

Open dakotawashok opened 2 weeks ago

dakotawashok commented 2 weeks 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 2 weeks ago

What database service are you using?

dakotawashok commented 2 weeks ago

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

jbrooksuk commented 2 weeks 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 2 weeks ago

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

dakotawashok commented 2 weeks 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 2 weeks 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 week 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 5 days 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 5 days ago

@jbrooksuk Absolutely, I'd be happy to!

jbrooksuk commented 5 days ago

Great! I look forward to it 😄

dakotawashok commented 3 days ago

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

jbrooksuk commented 2 days ago

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