Closed rechner closed 2 years ago
Heya, sorry for the issues. I'll do my best to help :)
I can see this line in your error log which means it can't find the /usr/src/data/setupcomplete
file inside the container (there should be a mapped volume which contains this and the sqlite database after a first run):
INFO: Detected a first time run. Populating the database with defaults.
Maybe double check where you're running the updated container from first. I don't think this would cause your other issue, but best to rule it out. :)
That being said, here is what I've found regarding your migration issue: At first I couldn't reproduce it; from an older database backup I have of my production instance, nor from an empty db. However, I think I remember hitting the same error during development one time and it was due to inconsistent data in the database so I did some digging and can now reproduce it. It looks like that inconsistent data is caused by the limitation of sqlite that you identified.
To fix it, use an sqlite GUI tool like TablePlus or sqlitebrowser (or CLI if you're crazy 😝). Have a look in the profile_profile_groups
table. You'll find one or more entries with a group_id
of 1
(according to your error). You can remove these and the migration should proceed without error.
Let me know if that works, and of course take a database backup first. :)
Thanks for the quick reply-
Since we're not open yet, I didn't have any attachment to the original database, and tried to spin up a new instance to check if that would work.
Per your advice, I decided to try deleting those entries on the old sqlite database and that worked! I'll give a spin up from scratch another try tomorrow, still interested in figuring out why I can't get mysql working :thinking:
Thanks again for the help.
Perfect! I'll close this issue for now then, but please open another one if you run into any more issues :)
Hello! Was super pleased to find this project, and am planning to use this at our up-and-coming hackerspace, @pawprintprototyping. I had an instance of the previous release, v2.6.3 running in a docker container with an sqlite database without much fuss, but in trying to upgrade I've run into an error running migrations:
Describe the bug When configured to use a new or existing sqlite database, I see this exception when Django tries to run migrations:
Sqlite startup container logs
``` web_1 | Operations to perform: web_1 | Apply all migrations: access, admin, api_admin_tools, api_general, api_meeting, auth, contenttypes, database, group, memberbucks, profile, sessions web_1 | Running migrations: web_1 | Traceback (most recent call last): web_1 | File "/usr/src/app/memberportal/manage.py", line 15, inLooking at the migration in question, my understanding is that the underlying problem comes down to a limitation of sqlite:
So, it will only be possible to run this migration on a new database that hasn't yet been populated by a fixture, and won't work on an existing database.
To Reproduce Steps to reproduce the behavior:
Additional context In the course of debugging, I tried setting up a mariadb instance to see if the migrations would work with that using this docker-compose:
docker-compose.yml
```yaml services: web: image: membermatters/membermatters:latest environment: PORTAL_DOMAIN: https://members.example.com PORTAL_ENV: Prodution MMDB_SECRET: '{"username": "root","host": "db","dbname": "members","password" :"members","port": 3306}' ports: - "8000:8000" depends_on: db: condition: service_healthy db: image: mariadb:latest environment: - MARIADB_DATABASE=members - MARIADB_ROOT_PASSWORD=members healthcheck: test: "/usr/bin/mysql --user=root --password=members --execute 'SHOW DATABASES;'" interval: 5s timeout: 1s retries: 5 ```Start the container and observe the logs:
Container logs
``` Traceback (most recent call last): File "/usr/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/usr/lib/python3.9/site-packages/django/db/backends/mysql/base.py", line 73, in execute return self.cursor.execute(query, args) File "/usr/lib/python3.9/site-packages/MySQLdb/cursors.py", line 206, in execute res = self._query(query) File "/usr/lib/python3.9/site-packages/MySQLdb/cursors.py", line 319, in _query db.query(q) File "/usr/lib/python3.9/site-packages/MySQLdb/connections.py", line 259, in query _mysql.connection.query(self, query) MySQLdb._exceptions.ProgrammingError: (1146, "Table 'membermatters.constance_config' doesn't exist") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/src/app/memberportal/./manage.py", line 15, inFrom what I can surmise, the problem in this configuration relates to the missing constance config, a bootstrapping problem: the migration script imports the models, which imports a view, which references a config key, which can't be resolved because the Constance migrations haven't run yet.
Additionally, I was hoping to be able to downgrade just changing the container tag, but it seems all tags except
latest
anddev
are removed from docker-hub, so I'll have to build.Anything else I can try to work around this?
Thanks!
[Update] some things I'm thinking of trying next: