File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,14 +150,15 @@ export default class PostgresDatabaseService implements IDatabaseService {
150150 //#region private
151151 async #runMigrations( ) : Promise < void > {
152152 await this . #runMigration( 'User soft delete' , async ( ) => {
153- await this . #database. query ( 'ALTER TABLE Users ADD isDeleted timestamp;' ) ;
153+ await this . #database. query ( 'ALTER TABLE Users ADD COLUMN IF NOT EXISTS isDeleted timestamp;' ) ;
154154 } ) ;
155155 }
156156
157157 async #runMigration( name : string , callback : ( ) => Promise < void > ) {
158158 const result = await this . #database. query ( 'SELECT * FROM Migrations WHERE name = $1' , [ name ] ) ;
159- const migration = [ ...result ] . pop ( ) ;
160- if ( ! migration ) {
159+
160+ this . #logger. verbose ( `Running migration "${ name } " with pre-query returning ${ JSON . stringify ( result ) } ` ) ;
161+ if ( result && result . rows . length === 0 ) {
161162 await this . #database. query ( 'INSERT INTO Migrations (name) VALUES($1);' , [ name ] ) ;
162163 await callback ( ) ;
163164 }
You can’t perform that action at this time.
0 commit comments