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

PostgreSQL database initialization seems to fail #137

Closed
mattock opened this issue Sep 10, 2024 · 4 comments
Closed

PostgreSQL database initialization seems to fail #137

mattock opened this issue Sep 10, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@mattock
Copy link

mattock commented Sep 10, 2024

I attempted to switch from SQLite to PostgreSQL (16.4) and ran into issues during database initialization:

2024-09-10 08:11:11.354 UTC [64] ERROR:  syntax error at or near "user" at character 13
2024-09-10 08:11:11.354 UTC [64] STATEMENT:  ALTER TABLE user ADD COLUMN email_confirmed BOOLEAN;

This repeat over and over again. I attempted to run the same command manually from the postgresql:16.4 container and the error was exactly the same. Database initialization did succeed partially, however:

otterwiki=# \dt
            List of relations
 Schema |    Name     | Type  |   Owner   
--------+-------------+-------+-----------
 public | drafts      | table | otterwiki
 public | preferences | table | otterwiki
(2 rows)

So, the database connectivity as configured in settings.cfg did work as expected.

Is postgresql supported / tested?

@redimp
Copy link
Owner

redimp commented Sep 10, 2024

Hey @mattock,

The _db_migrate() function is poorly implemented, I'm sorry for that. Will look into this and test it against at least postgres.

@redimp redimp added the bug Something isn't working label Sep 10, 2024
@redimp redimp self-assigned this Sep 10, 2024
@mattock
Copy link
Author

mattock commented Sep 10, 2024

@redimp ok, thanks!

@redimp redimp closed this as completed in f89829d Sep 10, 2024
@redimp
Copy link
Owner

redimp commented Sep 10, 2024

I've removed the obsolete and poorly implemented _db_migrate function, fixed some datatypes and lengths (that fortunately break nothing in SQlite.)

For testing I used this docker-compose.yaml:

---
services:
  web:
    build: .
    environment:
      SQLALCHEMY_DATABASE_URI: postgresql://postgres:example@db/postgres
    command:
      - /bin/bash
      - -c
      - |
        pip install psycopg2-binary
        /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
    depends_on:
      db:
        condition: service_started
        restart: true
    ports:
      - 8080:80

  db:
    image: postgres:16.4
    restart: always
    shm_size: 128mb
    environment:
      POSTGRES_PASSWORD: example

  adminer:
    image: adminer:4.8.1
    restart: always
    ports:
      - 8082:8080

@mattock
Copy link
Author

mattock commented Sep 18, 2024

PostgreSQL 16.4 seems to work fine now, thanks @redimp !

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