Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using Postgres database without public schema #536

Open
acelinkio opened this issue Jun 15, 2024 · 1 comment
Open

Support using Postgres database without public schema #536

acelinkio opened this issue Jun 15, 2024 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@acelinkio
Copy link
Contributor

Kyoo's version

4.6.0

What happened?

Unable to use database/user without public schema. The first pass of the migration container runs successfully and the application starts. However if the migration container runs again, it errors out with the following message.

Failed executing DbCommand (11ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CREATE TABLE "__EFMigrationsHistory" (
    migration_id character varying(150) NOT NULL,
    product_version character varying(32) NOT NULL,
    CONSTRAINT pk___ef_migrations_history PRIMARY KEY (migration_id)
);
Npgsql.PostgresException (0x80004005): 42P07: relation "__EFMigrationsHistory" already exists
   at Npgsql.Internal.NpgsqlConnector.ReadMessageLong(Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
   at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.Sources.IValueTaskSource<TResult>.GetResult(Int16 token)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlDataReader.NextResult()
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(Boolean async, CommandBehavior behavior, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteNonQuery()

When running using the public schema, migration container completes without error even on restart.

No migrations were applied. The database is already up to date.
Done.

example manifest

apiVersion: apps/v1
kind: Deployment
metadata:
  name: kyoo-back
  namespace: kyoo
  labels:
    app.kubernetes.io/component: back
    app.kubernetes.io/instance: kyoo
    app.kubernetes.io/name: kyoo
  annotations:
    reloader.stakater.com/auto: "true"
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/component: back
      app.kubernetes.io/name: kyoo
      app.kubernetes.io/instance: kyoo
  template:
    metadata:
      labels:
        app.kubernetes.io/component: back
        app.kubernetes.io/instance: kyoo
        app.kubernetes.io/name: kyoo
    spec:
      initContainers:
        - env:
            - name: POSTGRES_USER
              value: datatestdb_owner_user
            - name: POSTGRES_PASSWORD
              value: REDACTED
            - name: POSTGRES_DB
              value: datatestdb
            - name: POSTGRES_SERVER
              value: cluster02.postgres
            - name: POSTGRES_PORT
              value: "5432"
          image: ghcr.io/zoriya/kyoo_migrations:edge
          name: postgres-migrations
      containers:
        - env:
            - name: TRANSCODER_URL
              value: http://transcoder.kyoo:7666
            - name: PUBLIC_URL
              value: http://localhost:8901
            - name: KYOO_APIKEYS
              value: REDACTED
            - name: POSTGRES_USER
              value: datatestdb_owner_user
            - name: POSTGRES_PASSWORD
              value: REDACTED
            - name: POSTGRES_DB
              value: datatestdb
            - name: POSTGRES_SERVER
              value: cluster02.postgres
            - name: POSTGRES_PORT
              value: "5432"
            - name: RABBITMQ_DEFAULT_USER
              value: default_user_EVdxzNQAcVY5ek6UO8B
            - name: RABBITMQ_DEFAULT_PASS
              value: REDACTED
            - name: RABBITMQ_HOST
              value: cluster01.rabbitmq
            - name: RABBITMQ_Port
              value: "5672"
            - name: MEILI_HOST
              value: http://meilisearch.kyoo:7700
            - name: MEILI_MASTER_KEY
              value: REDACTED
          image: ghcr.io/zoriya/kyoo_back:edge
          name: backend
          volumeMounts:
            - mountPath: /metadata
              name: backend
            - mountPath: /data
              name: media
              readOnly: true
              subPath: media
      volumes:
        - name: backend
          persistentVolumeClaim:
            claimName: backend
        - name: media
          persistentVolumeClaim:
            claimName: media
@acelinkio acelinkio added the bug Something isn't working label Jun 15, 2024
@zoriya zoriya added this to the v5.0.0 milestone Aug 8, 2024
@zoriya
Copy link
Owner

zoriya commented Aug 8, 2024

the transcoder now uses it's own schema, the backend will be reworked in v5 (and won't use the public schema)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants