horilla-opensource / horilla

Horilla is a free and open source HR software.
https://www.horilla.com/
GNU Lesser General Public License v2.1
83 stars 43 forks source link

Unknown column 'pms_employee....' #123

Open curtishall opened 1 month ago

curtishall commented 1 month ago

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

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.

horilla-opensource commented 1 month ago

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

curtishall commented 1 month ago

Sorry...I meant git pull not docker.

horilla-opensource commented 1 month ago

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

CodeMouse92 commented 1 month ago

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)
horilla-opensource commented 1 month ago

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

CodeMouse92 commented 1 month ago

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 commented 1 month ago

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...
                                                             ^
horilla-opensource commented 1 month ago

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

With Regards, Team Horilla

CodeMouse92 commented 1 month ago

Fresh database.

curtishall commented 1 month ago

Any updates on this?

horilla-opensource commented 1 month ago

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

curtishall commented 1 month ago

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
horilla-opensource commented 1 month ago

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

With Regards, Team Horilla

curtishall commented 1 month ago

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: @.***>

horilla-opensource commented 1 month ago

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 commented 3 weeks ago

Hi @curtishall , Any updates?

With Regards, Team Horilla