mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 07:06:28 +08:00
fix(server): add embedding table repair (#14895)
fix #14894 #### PR Dependency Tree * **PR #14895** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved database initialization for self-hosted deployments with automatic creation and repair of embedding tables and indexes, applied only when related base tables and extensions are present. * Updated pre-deploy process to run Prisma migrations, perform embedding-table maintenance, and execute additional data migrations as part of setup. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -38,9 +38,32 @@ function prepare() {
|
||||
}
|
||||
}
|
||||
|
||||
function runPredeployScript() {
|
||||
console.log('running predeploy script.');
|
||||
execSync('yarn predeploy', {
|
||||
function runPrismaMigrations() {
|
||||
console.log('running prisma migrations.');
|
||||
execSync('yarn prisma migrate deploy', {
|
||||
encoding: 'utf-8',
|
||||
env: process.env,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
|
||||
function repairPgvectorEmbeddingTables() {
|
||||
console.log('repairing copilot pgvector embedding tables.');
|
||||
const sql = fs.readFileSync(
|
||||
path.join(import.meta.dirname, 'repair-pgvector-embedding-tables.sql'),
|
||||
'utf-8'
|
||||
);
|
||||
execSync('yarn prisma db execute --stdin --schema schema.prisma', {
|
||||
encoding: 'utf-8',
|
||||
env: process.env,
|
||||
input: sql,
|
||||
stdio: ['pipe', 'inherit', 'inherit'],
|
||||
});
|
||||
}
|
||||
|
||||
function runDataMigrations() {
|
||||
console.log('running data migrations.');
|
||||
execSync('yarn cli run', {
|
||||
encoding: 'utf-8',
|
||||
env: process.env,
|
||||
stdio: 'inherit',
|
||||
@@ -85,4 +108,6 @@ function fixFailedMigrations() {
|
||||
|
||||
prepare();
|
||||
fixFailedMigrations();
|
||||
runPredeployScript();
|
||||
runPrismaMigrations();
|
||||
repairPgvectorEmbeddingTables();
|
||||
runDataMigrations();
|
||||
|
||||
Reference in New Issue
Block a user