install-pgvector.bat•4.37 kB
@echo off
REM Quick pgvector Installation Script
REM Uses pre-built binaries - no compilation needed!
title Install pgvector for PostgreSQL
color 0A
echo.
echo ========================================
echo pgvector Quick Installation
echo For PostgreSQL 16 on Windows
echo ========================================
echo.
REM Check PostgreSQL installation
echo [1/5] Checking PostgreSQL installation...
if not exist "C:\Program Files\PostgreSQL\16" (
echo [!] PostgreSQL 16 not found at default location
echo Please adjust the PGROOT path below if installed elsewhere
pause
exit /b 1
)
set PGROOT=C:\Program Files\PostgreSQL\16
echo [OK] PostgreSQL 16 found
echo.
REM Check if pgvector already installed
echo [2/5] Checking if pgvector already installed...
psql -U postgres -d postgres -c "SELECT * FROM pg_available_extensions WHERE name='vector'" 2>nul | find "vector" >nul
if %ERRORLEVEL% EQU 0 (
echo [i] pgvector may already be installed
echo Let's verify and reinstall if needed...
)
echo.
REM Download pre-built binaries
echo [3/5] Downloading pgvector pre-built binaries...
echo Downloading from GitHub releases...
echo.
powershell -Command "& {Invoke-WebRequest -Uri 'https://github.com/pgvector/pgvector/releases/download/v0.8.1/pgvector-v0.8.1-windows-x64.zip' -OutFile '%TEMP%\pgvector.zip'}"
if %ERRORLEVEL% NEQ 0 (
echo [!] Download failed
echo Please download manually from: https://github.com/pgvector/pgvector/releases
pause
exit /b 1
)
echo [OK] Downloaded to %TEMP%\pgvector.zip
echo.
REM Extract files
echo [4/5] Extracting files...
powershell -Command "& {Expand-Archive -Path '%TEMP%\pgvector.zip' -DestinationPath '%TEMP%\pgvector' -Force}"
echo [OK] Extracted to %TEMP%\pgvector
echo.
REM Copy files to PostgreSQL directories
echo [5/5] Installing pgvector files...
echo This requires Administrator privileges...
echo.
REM Copy DLL
echo Copying vector.dll...
copy /Y "%TEMP%\pgvector\vector.dll" "%PGROOT%\lib\vector.dll" >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo [!] Failed to copy vector.dll
echo Please run this script as Administrator
echo Or manually copy files:
echo From: %TEMP%\pgvector\vector.dll
echo To: %PGROOT%\lib\
pause
exit /b 1
)
echo [OK] vector.dll copied
REM Copy control file
echo Copying vector.control...
copy /Y "%TEMP%\pgvector\vector.control" "%PGROOT%\share\extension\vector.control" >nul 2>&1
echo [OK] vector.control copied
REM Copy SQL files
echo Copying SQL files...
for %%f in ("%TEMP%\pgvector\vector--*.sql") do (
copy /Y "%%f" "%PGROOT%\share\extension\" >nul 2>&1
)
echo [OK] SQL files copied
echo.
REM Restart PostgreSQL
echo [6/6] Restarting PostgreSQL service...
net stop postgresql-x64-16 2>nul
timeout /t 2 /nobreak >nul
net start postgresql-x64-16 2>nul
if %ERRORLEVEL% NEQ 0 (
echo [!] Could not restart service automatically
echo Please restart manually:
echo 1. Open Services (services.msc)
echo 2. Find "postgresql-x64-16"
echo 3. Right-click and Restart
pause
) else (
echo [OK] PostgreSQL restarted
)
echo.
REM Verify installation
echo ========================================
echo Verifying Installation
echo ========================================
echo.
echo Testing pgvector extension...
psql -U postgres -d postgres -c "CREATE EXTENSION IF NOT EXISTS vector;" 2>nul
if %ERRORLEVEL% EQU 0 (
echo [OK] pgvector extension created successfully!
echo.
psql -U postgres -d postgres -c "SELECT extname, extversion FROM pg_extension WHERE extname='vector';"
) else (
echo [!] Could not create extension
echo Please try manually:
echo psql -U postgres
echo CREATE EXTENSION vector;
)
echo.
REM Cleanup
echo Cleaning up temporary files...
del /Q "%TEMP%\pgvector.zip" 2>nul
rmdir /S /Q "%TEMP%\pgvector" 2>nul
echo.
echo ========================================
echo Installation Complete!
echo ========================================
echo.
echo Next steps:
echo 1. Create your database:
echo psql -U postgres -c "CREATE DATABASE quoting_db;"
echo.
echo 2. Enable pgvector in your database:
echo psql -U postgres -d quoting_db -c "CREATE EXTENSION vector;"
echo.
echo 3. Run project setup:
echo cd C:\Users\Rich\OneDrive\Projects\Quoting
echo setup-phase1.bat
echo.
pause