Han Hsu
Han Hsu

Reputation: 23

Laravel Postgres SQL could not open extension "vector.control"

when I use php artisan migrate. I will show me
"SQLSTATE[58P01]: Undefined file: 7 ERROR: could not open extension control file "/usr/share/postgresql/12/extension/vector.control": No such file or directory (Connection: pgsql, SQL: CREATE EXTENSION IF NOT EXISTS vector)"

what should I do to fix this problem.

hope someone can help me. Thank you everyone

 Creating migration table ................................................................................................................ 3ms DONE

   INFO  Running migrations.  

  2014_10_12_000000_create_users_table .................................................................................................... 5ms DONE
  2014_10_12_100000_create_password_reset_tokens_table .................................................................................... 3ms DONE
  2014_10_12_200000_add_two_factor_columns_to_users_table ................................................................................. 1ms DONE
  2019_08_19_000000_create_failed_jobs_table .............................................................................................. 4ms DONE
  2019_12_14_000001_create_personal_access_tokens_table ................................................................................... 4ms DONE
  2020_05_21_100000_create_teams_table .................................................................................................... 3ms DONE
  2020_05_21_200000_create_team_user_table ................................................................................................ 3ms DONE
  2020_05_21_300000_create_team_invitations_table ......................................................................................... 7ms DONE
  2022_08_03_000000_create_vector_extension ............................................................................................... 1ms FAIL

   Illuminate\Database\QueryException 

  SQLSTATE[58P01]: Undefined file: 7 ERROR:  could not open extension control file "/usr/share/postgresql/12/extension/vector.control": No such file or directory (Connection: pgsql, SQL: CREATE EXTENSION IF NOT EXISTS vector)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:793
    789▕         // If an exception occurs when attempting to run a query, we'll format the error
    790▕         // message to include the bindings with SQL, which will make this exception a
    791▕         // lot more helpful to the developer instead of just the database's errors.
    792▕         catch (Exception $e) {
 ➜ 793▕             throw new QueryException(
    794▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    795▕             );
    796▕         }
    797▕     }

      +44 vendor frames 

  45  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Upvotes: 2

Views: 11026

Answers (1)

Erik Roznbeker
Erik Roznbeker

Reputation: 734

Before enabling vector extension in Postgres (CREATE EXTENSION IF NOT EXISTS vector), pgvector extension must be installed.

On their GitHub page https://github.com/pgvector/pgvector, there are multiple ways how you can install or find already prepared Postgres versions. For local development I use Postgres.app or docker and they both come with preinstalled pgvector extension so I just run create extension and it works out of the box.

Upvotes: 0

Related Questions