mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 19:28:09 +00:00
Fix ca version migration
We didn't do a check to see if the column already exists. Because of this, we get this error during migrations: ``` | migration file "20240802181855_ca-cert-version.ts" failed infisical-db-migration | migration failed with error: alter table "certificates" add column "caCertId" uuid null - column "caCertId" of relation "certificates" already exists ```
This commit is contained in:
@@ -64,23 +64,25 @@ export async function up(knex: Knex): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (await knex.schema.hasTable(TableName.Certificate)) {
|
if (await knex.schema.hasTable(TableName.Certificate)) {
|
||||||
await knex.schema.alterTable(TableName.Certificate, (t) => {
|
const hasCaCertIdColumn = await knex.schema.hasColumn(TableName.Certificate, "caCertId");
|
||||||
t.uuid("caCertId").nullable();
|
if (!hasCaCertIdColumn) {
|
||||||
t.foreign("caCertId").references("id").inTable(TableName.CertificateAuthorityCert);
|
await knex.schema.alterTable(TableName.Certificate, (t) => {
|
||||||
});
|
t.uuid("caCertId").nullable();
|
||||||
|
t.foreign("caCertId").references("id").inTable(TableName.CertificateAuthorityCert);
|
||||||
|
});
|
||||||
|
|
||||||
await knex.raw(`
|
await knex.raw(`
|
||||||
UPDATE "${TableName.Certificate}" cert
|
UPDATE "${TableName.Certificate}" cert
|
||||||
SET "caCertId" = (
|
SET "caCertId" = (
|
||||||
SELECT caCert.id
|
SELECT caCert.id
|
||||||
FROM "${TableName.CertificateAuthorityCert}" caCert
|
FROM "${TableName.CertificateAuthorityCert}" caCert
|
||||||
WHERE caCert."caId" = cert."caId"
|
WHERE caCert."caId" = cert."caId"
|
||||||
)
|
)`);
|
||||||
`);
|
|
||||||
|
|
||||||
await knex.schema.alterTable(TableName.Certificate, (t) => {
|
await knex.schema.alterTable(TableName.Certificate, (t) => {
|
||||||
t.uuid("caCertId").notNullable().alter();
|
t.uuid("caCertId").notNullable().alter();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+59
-59
@@ -3,70 +3,70 @@ version: "3"
|
|||||||
services:
|
services:
|
||||||
db-migration:
|
db-migration:
|
||||||
container_name: infisical-db-migration
|
container_name: infisical-db-migration
|
||||||
depends_on:
|
# depends_on:
|
||||||
db:
|
# db:
|
||||||
condition: service_healthy
|
# condition: service_healthy
|
||||||
image: infisical/infisical:latest-postgres
|
image: infisical/infisical:v0.94.0-postgres
|
||||||
env_file: .env
|
env_file: .env
|
||||||
command: npm run migration:latest
|
command: npm run migration:latest
|
||||||
pull_policy: always
|
pull_policy: always
|
||||||
networks:
|
# networks:
|
||||||
- infisical
|
# - infisical
|
||||||
|
|
||||||
backend:
|
# backend:
|
||||||
container_name: infisical-backend
|
# container_name: infisical-backend
|
||||||
restart: unless-stopped
|
# restart: unless-stopped
|
||||||
depends_on:
|
# depends_on:
|
||||||
db:
|
# db:
|
||||||
condition: service_healthy
|
# condition: service_healthy
|
||||||
redis:
|
# redis:
|
||||||
condition: service_started
|
# condition: service_started
|
||||||
db-migration:
|
# db-migration:
|
||||||
condition: service_completed_successfully
|
# condition: service_completed_successfully
|
||||||
image: infisical/infisical:latest-postgres
|
# image: infisical/infisical:latest-postgres
|
||||||
pull_policy: always
|
# pull_policy: always
|
||||||
env_file: .env
|
# env_file: .env
|
||||||
ports:
|
# ports:
|
||||||
- 80:8080
|
# - 80:8080
|
||||||
environment:
|
# environment:
|
||||||
- NODE_ENV=production
|
# - NODE_ENV=production
|
||||||
networks:
|
# networks:
|
||||||
- infisical
|
# - infisical
|
||||||
|
|
||||||
redis:
|
# redis:
|
||||||
image: redis
|
# image: redis
|
||||||
container_name: infisical-dev-redis
|
# container_name: infisical-dev-redis
|
||||||
env_file: .env
|
# env_file: .env
|
||||||
restart: always
|
# restart: always
|
||||||
environment:
|
# environment:
|
||||||
- ALLOW_EMPTY_PASSWORD=yes
|
# - ALLOW_EMPTY_PASSWORD=yes
|
||||||
ports:
|
# ports:
|
||||||
- 6379:6379
|
# - 6379:6379
|
||||||
networks:
|
# networks:
|
||||||
- infisical
|
# - infisical
|
||||||
volumes:
|
# volumes:
|
||||||
- redis_data:/data
|
# - redis_data:/data
|
||||||
|
|
||||||
db:
|
# db:
|
||||||
container_name: infisical-db
|
# container_name: infisical-db
|
||||||
image: postgres:14-alpine
|
# image: postgres:14-alpine
|
||||||
restart: always
|
# restart: always
|
||||||
env_file: .env
|
# env_file: .env
|
||||||
volumes:
|
# volumes:
|
||||||
- pg_data:/var/lib/postgresql/data
|
# - pg_data:/var/lib/postgresql/data
|
||||||
networks:
|
# networks:
|
||||||
- infisical
|
# - infisical
|
||||||
healthcheck:
|
# healthcheck:
|
||||||
test: "pg_isready --username=${POSTGRES_USER} && psql --username=${POSTGRES_USER} --list"
|
# test: "pg_isready --username=${POSTGRES_USER} && psql --username=${POSTGRES_USER} --list"
|
||||||
interval: 5s
|
# interval: 5s
|
||||||
timeout: 10s
|
# timeout: 10s
|
||||||
retries: 10
|
# retries: 10
|
||||||
|
|
||||||
volumes:
|
# volumes:
|
||||||
pg_data:
|
# pg_data:
|
||||||
driver: local
|
# driver: local
|
||||||
redis_data:
|
# redis_data:
|
||||||
driver: local
|
# driver: local
|
||||||
|
|
||||||
networks:
|
# networks:
|
||||||
infisical:
|
# infisical:
|
||||||
|
|||||||
Reference in New Issue
Block a user