horilla icon indicating copy to clipboard operation
horilla copied to clipboard

Unknown column 'pms_employee....'

Open curtishall opened this issue 1 year ago • 16 comments
trafficstars

Bug Report

Description

I did a docker pull and made sure to run the makemigration and migrate however when I start the server I see this, followed by many django.db.utils errors (obviously)

root@horilla:~/horilla# python3 manage.py runserver 0.0.0.0:8000
(1054, "Unknown column 'pms_employeeobjective.objective_id_id' in 'field list'")
(1054, "Unknown column 'pms_employeekeyresult.key_result_id_id' in 'field list'")
(1054, "Unknown column 'pms_employeeobjective.objective_id_id' in 'field list'")
(1054, "Unknown column 'pms_employeekeyresult.key_result_id_id' in 'field list'")
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
March 16, 2024 - 15:22:24
Django version 4.2.7, using settings 'horilla.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.

Steps to Reproduce

  1. [Detailed step-by-step instructions to reproduce the issue.]

Expected Behavior

[What you expected to happen.]

Actual Behavior

[What actually happened.]

Screenshots

[If applicable, provide screenshots illustrating the issue.]

Environment

  • Django Version: [Django version you're using, e.g., 3.2.1]
  • Python Version: [Python version, e.g., 3.9]
  • Operating System: [Your OS, e.g., Windows 10, Ubuntu 20.04]
  • Browser: [If applicable, specify the browser and version you're using.]

Additional Information

[Any other relevant information, logs, error messages, or context that might help in understanding and fixing the issue.]

Possible Solution

[If you have any ideas or suggestions on how to fix the issue, feel free to provide them here. This is optional.]

Labels

[If your project uses labels, suggest any labels that might apply to this issue, such as 'bug', 'needs investigation', etc.]

Priority

[Specify the priority level for this issue, such as 'high', 'medium', 'low', etc.]

Assignees

[If you want to suggest an assignee or tag a specific person to look into this issue, mention their GitHub username here.]

Related Issues

[If there are any related issues or pull requests, mention them here. This is optional.]

Note: Remember to search through existing issues before submitting a new one to ensure that the issue hasn't been reported already. Provide as much information as possible to help the maintainers understand and address the problem effectively.

curtishall avatar Mar 16 '24 20:03 curtishall

Hi @curtishall , We haven't added an official docker image in the docker hub till now. We have added an test image for our testing purpose of CI/ CD. Can you mention the repo from which you have pulled the docker image?

With Regards, Team Horilla

horilla-opensource avatar Mar 17 '24 07:03 horilla-opensource

Sorry...I meant git pull not docker.

curtishall avatar Mar 17 '24 13:03 curtishall

Hi @curtishall , The solution for the above issue is added in the commit [FIX] PMS: Updated peformance model objective and key result by adding related name for HorillaCompanyManager field . Please check and let us know if this fixed the issue for you.

With Regards, Team Horilla

horilla-opensource avatar Mar 18 '24 11:03 horilla-opensource

I'm getting much the same error on makemigrations and migrate, along with some further warnings about accessing during initialization (fresh database).

/opt/horilla/venv/lib/python3.10/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
relation "pms_employeeobjective" does not exist
LINE 1: ...rcentage", "pms_employeeobjective"."archive" FROM "pms_emplo...
                                                             ^

relation "pms_employeekeyresult" does not exist
LINE 1: ...pms_employeekeyresult"."progress_percentage" FROM "pms_emplo...
                                                             ^

/opt/horilla/venv/lib/python3.10/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)

Happy to open a separate ticket for the "Accessing the database during app initialization is discouraged" errors, which I also get on runserver. I simply don't know if they're related, or a separate problem.

/opt/horilla/venv/lib/python3.10/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
/opt/horilla/venv/lib/python3.10/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
/opt/horilla/venv/lib/python3.10/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
/opt/horilla/venv/lib/python3.10/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
  • Ubuntu 22.04
  • Fresh installation of Horilla today from master; same issues on 1.0.0 tag.
  • PostgreSQL database

CodeMouse92 avatar Mar 22 '24 18:03 CodeMouse92

Hi @CodeMouse92 , We'll check on the first issue that you mentioned once again. The second issue with the warnings is maybe because of the your django version. I think you are using django v5, which is also supported, but raises some warnings sometimes. Maybe you can downgrade your django versions v4 (>=4.2.11 preferred) and check again.

Please let us know if that solved your second issue. With Regards, Team Horilla

horilla-opensource avatar Mar 22 '24 19:03 horilla-opensource

That appears to fix both issues, so perhaps this is related to Django 5 altogether. (Mind you, I'm getting a 500 when serving via Apache2, but I suspect that's altogether unrelated.)

CodeMouse92 avatar Mar 22 '24 19:03 CodeMouse92

Correction, it does not fully fix it. I have this error still on makemigrations:

elation "pms_employeeobjective" does not exist
LINE 1: ...rcentage", "pms_employeeobjective"."archive" FROM "pms_emplo...
                                                             ^

relation "pms_employeekeyresult" does not exist
LINE 1: ...pms_employeekeyresult"."progress_percentage" FROM "pms_emplo...
                                                             ^

CodeMouse92 avatar Mar 22 '24 19:03 CodeMouse92

Hi @CodeMouse92 , Can we know whether you are using the test database or a fresh database?

With Regards, Team Horilla

horilla-opensource avatar Mar 22 '24 20:03 horilla-opensource

Fresh database.

CodeMouse92 avatar Mar 22 '24 20:03 CodeMouse92

Any updates on this?

curtishall avatar Mar 27 '24 23:03 curtishall

Hi @curtishall , Yes, the issue is fixed in the latest commits. You can check with the latest code. With Regards, Team Horilla

horilla-opensource avatar Mar 28 '24 09:03 horilla-opensource

latest commit, I ran migrate and makemigrations:

 "Table 'horilla.base_dashboardemployeecharts' doesn't exist")</pre>
Request Method: | GET
-- | --
http://hrms.callawayso.org/
4.2.7
ProgrammingError
(1146, "Table 'horilla.base_dashboardemployeecharts' doesn't exist")
/usr/local/lib/python3.10/dist-packages/MySQLdb/connections.py, line 254, in query
horilla.decorators.wrapped_view
/usr/bin/python3
3.10.12
['/root/horilla',  '/usr/lib/python310.zip',  '/usr/lib/python3.10',  '/usr/lib/python3.10/lib-dynload',  '/usr/local/lib/python3.10/dist-packages',  '/usr/lib/python3/dist-packages']
Sun, 31 Mar 2024 18:48:27 -0500

curtishall avatar Mar 31 '24 23:03 curtishall

Hi @curtishall , Did you anyone cleared out the migrations folder from the codebase?

With Regards, Team Horilla

horilla-opensource avatar Apr 03 '24 04:04 horilla-opensource

I don’t know what you mean or how to do that.

Sent from Gmail Mobile

On Tue, Apr 2, 2024 at 11:34 PM Horilla @.***> wrote:

Hi @curtishall https://github.com/curtishall , Did you anyone cleared out the migrations folder from the codebase?

With Regards, Team Horilla

— Reply to this email directly, view it on GitHub https://github.com/horilla-opensource/horilla/issues/123#issuecomment-2033512414, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACQ5VTDT7FRZVDN3T2LF63Y3OBEBAVCNFSM6AAAAABEZSO5PGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZTGUYTENBRGQ . You are receiving this because you were mentioned.Message ID: @.***>

curtishall avatar Apr 03 '24 14:04 curtishall

Hi @curtishall , Sorry for that. I meant to ask if you have removed the directory or files inside the migrations ? This file will be located inside every app for Horilla. If there is no changes made to that folder/ files the makemigrations command will load this new models into your database structure. As a walkaround for the issue that your are facing, we'll provide a solution to it. Please follow the following steps. (please do take a backup of the current database, incase something bad happens)

  1. Go to base/migrations folder.
  2. Check for the last file with name starting 000x.py
  3. Traverse through that file and check for a content similar to the one below. operations = [ migrations.CreateModel( name='DashboardEmployeeCharts', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created_at', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Created At')), ('is_active', models.BooleanField(default=True, verbose_name='Is Active')), ('charts', models.JSONField(blank=True, null=True)), ('created_by', models.ForeignKey(blank=True, editable=False, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Created By')), ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='employee.employee')), ], options={ 'abstract': False, }, ), ]
  4. Once you find this, comment out the line complete section and run the makemigrations and migrate command.

Please let us know, if this fixed your issue.

With Regards. Team Horilla

horilla-opensource avatar Apr 04 '24 05:04 horilla-opensource

Hi @curtishall , Any updates?

With Regards, Team Horilla

horilla-opensource avatar Apr 22 '24 08:04 horilla-opensource

Hi @curtishall , We are closing this issue due to inactivity. It seems that there hasn't been any recent activity or discussion, and we believe it may have been resolved or is no longer relevant. If you feel this issue is still important and should be addressed, please feel free to reopen it or create a new issue with updated details.

With Regards, Team Horilla

horilla-opensource avatar Jul 25 '24 05:07 horilla-opensource