statamic-rad-pack / runway

Eloquently manage your database models in Statamic.
https://statamic.com/runway
MIT License
107 stars 43 forks source link

Not compatible with statamic/eloquent-driver #465

Closed andreas-eisenmann closed 3 months ago

andreas-eisenmann commented 3 months ago

Description

I want to integrate runway in a statamic project in combination with statamic/eloquent-driver. Now I am not able to rebuild the project (with a fresh, not yet migrated database) anymore. Running composer install throws an exception:

  - Downloading statamic-rad-pack/runway (dist)
  - Installing statamic-rad-pack/runway (dist): Extracting archive
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   Illuminate\Database\QueryException 

  could not find driver (Connection: pgsql, SQL: select * from "blueprints" where "namespace" = runway)

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

      +40 vendor frames 

  41  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Why: we are in a very "early" stage and the database has not been migrated yet, since it's the first run of composer install in context of initialisation of the application.

I found a very hacky workaround by disabling auto discovery of statamic-rad-pack/runway and extending the service provider of this addon. In my custom service provider I've extended registerBlueprints() by a check if we can connect to the database and the table blueprints exists.

With the the possibility to register/sync blueprints manually by running runway:generate-blueprints, the easiest and safest solution would be to introduce a new config parameter disable_register_blueprints in the same way as disable_migrations.

Steps to reproduce

  1. Install Statamic CMS
  2. Require statamic/eloquent-driver and statamic-rad-pack/runway
  3. Define at least one resource (with a blueprint) in config.runway.resources
  4. Rebuild the whole project (important: start with a fresh database)

Environment

Environment Application Name: ** Laravel Version: 10.43.0 PHP Version: 8.2.12 Composer Version: 2.6.5 Environment: local Debug Mode: ENABLED URL: localhost Maintenance Mode: OFF

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: NOT CACHED

Drivers Broadcasting: log Cache: statamic Database: pgsql Logs: stack / single Mail: smtp Queue: sync Session: file

Locales Installed Locales Version: 1.9.0 Protected

Localization Installed: de, en LaravelLang\Attributes\Plugin: 2.5.0 LaravelLang\HttpStatuses\Plugin: 3.6.1 LaravelLang\Lang\Plugin: 13.6.1 Protected Locales: de, en Publisher Version: 14.7.1

Statamic Addons: 2 Antlers: runtime Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 4.52.0 PRO

Statamic Addons statamic-rad-pack/runway: 6.0.6 statamic/eloquent-driver: 3.3.2

Statamic Eloquent Driver Asset Containers: eloquent Assets: eloquent Blueprints: eloquent Collection Trees: eloquent Collections: eloquent Entries: eloquent Forms: eloquent Global Sets: eloquent Global Variables: eloquent Navigation Trees: eloquent Navigations: eloquent Revisions: eloquent Taxonomies: eloquent Terms: eloquent

github-actions[bot] commented 3 months ago

Released as part of v6.6.2.