Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lunar 1.0: SQL Migration error when running migrations for the first time. #1698

Open
Timtendo12 opened this issue Apr 15, 2024 · 2 comments
Labels
1.x bug Something isn't working

Comments

@Timtendo12
Copy link

Timtendo12 commented Apr 15, 2024

  • Lunar version: 1.0.0-alpha.9
  • Laravel Version: 11
  • PHP Version: 8.3.4
  • Database Driver & Version: MariaDB 10.4.28

Expected Behaviour:

Running all migrations without errors.

Actual Behaviour:

I get an error when running migrations on the following table:

2022_01_18_100000_add_starts_ends_at_to_channelables_table

error:

SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'starts_at' (Connection: mysql, SQL: alter table `lunar_channelables` change `published_at` `starts_at` datetime null default 'NULL'

Steps To Reproduce:

  1. Start a fresh laravel project
  2. Install lunar composer require lunarphp/lunar:"^1.0.0-alpha" -W
  3. run migrations php artisan migrate
@Timtendo12 Timtendo12 added bug Something isn't working unconfirmed labels Apr 15, 2024
@Timtendo12
Copy link
Author

Potentional fix could be changing the migration to:

    public function up()
    {
        /**
         * SQLite will only allow one per transaction when modifying columns.
         */
        Schema::table($this->prefix.'channelables', function (Blueprint $table) {
           $table->renameColumn('published_at', 'starts_at')->nullable()->change();
           $table->index('starts_at');
        });

        Schema::table($this->prefix.'channelables', function (Blueprint $table) {
            $table->dateTime('ends_at')->after('starts_at')->nullable()->index();
        });
    }

@alecritson
Copy link
Collaborator

Strange one, I've not come against this and we do have a test case which should run migrations and then rollback to ensure this kind of thing works. If you think this is a fix then happy to see a PR and we can take a look :)

@glennjacobs glennjacobs added the 1.x label May 20, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants