php-telegram-bot / laravel

Laravel package for PHP Telegram Bot Library
Other
171 stars 51 forks source link

Migrations are broken because of `->index('user_id')` #39

Closed agilov closed 3 years ago

agilov commented 3 years ago

Cannot run migrations of a fresh database:

bash-5.1# php artisan migrate
Migrating: 2018_04_18_193554_create_botan_shortener_table
Migrated:  2018_04_18_193554_create_botan_shortener_table (73.51ms)
Migrating: 2018_04_18_193554_create_callback_query_table

   Illuminate\Database\QueryException

  SQLSTATE[42P07]: Duplicate table: 7 ERROR:  relation "user_id" already exists (SQL: create index "user_id" on "callback_query" ("user_id"))

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:703
    699▕         // If an exception occurs when attempting to run a query, we'll format the error
    700▕         // message to include the bindings with SQL, which will make this exception a
    701▕         // lot more helpful to the developer instead of just the database's errors.
    702▕         catch (Exception $e) {
  ➜ 703▕             throw new QueryException(
    704▕                 $query, $this->prepareBindings($bindings), $e
    705▕             );
    706▕         }
    707▕     }

      +9 vendor frames
  10  modules/Bot/database/migrations/2018_04_18_193554_create_callback_query_table.php:22
      Illuminate\Support\Facades\Facade::__callStatic("create")

      +22 vendor frames
  33  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Usage of ->index('user_id') function causes this issue. Index should have an unique name or is better to omit index name in this function call. Also there are a lot of ->index('chat_id') usages that also will cause the same trouble.

agilov commented 3 years ago

I tried it on postgres. So this issue is wrong.