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 44 forks source link

Error when applying migration pms.0008_keyresult_alter_feedback_options_and_more #136

Open sergej-wv opened 1 month ago

sergej-wv commented 1 month ago

Bug Report

Description

When updating the application to the latest state of the master or 1.0 branch an exception is thrown when appliying the migrations.

Steps to Reproduce

  1. fetch all files from git
  2. install python dependencies
  3. execute command makemigrations
  4. execute migrate

Expected Behavior

All migrations get applied.

Actual Behavior

Error output:

python manage.py migrate Operations to perform: Apply all migrations: admin, asset, attendance, auth, base, contenttypes, django_apscheduler, employee, helpdesk, horilla_audit, horilla_documents, leave, notifications, offboarding, onboarding, payroll, pms, recruitment, sessions Running migrations: Applying pms.0008_keyresult_alter_feedback_options_and_more...Traceback (most recent call last): File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2053, in get_prep_value return int(value) TypeError: int() argument must be a string, a bytes-like object or a real number, not 'datetime.datetime' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/opt/horilla/horilla/manage.py", line 22, in main() File "/opt/horilla/horilla/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv self.execute(*args, **cmd_options) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute output = self.handle(*args, **options) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/core/management/base.py", line 106, in wrapper res = handle_func(*args, **kwargs) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 356, in handle post_migrate_state = executor.migrate( File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate state = self._migrate_all_forwards( File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards state = self.apply_migration( File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration state = migration.apply(state, schema_editor) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 132, in apply operation.database_forwards( File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 108, in database_forwards schema_editor.add_field( File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 398, in add_field self._remake_table(model, create_field=field) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 238, in _remake_table self.effective_default(create_field), File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 429, in effective_default return field.get_db_prep_save(self._effective_default(field), self.connection) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/models/fields/related.py", line 1129, in get_db_prep_save return self.target_field.get_db_prep_save(value, connection=connection) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 954, in get_db_prep_save return self.get_db_prep_value(value, connection=connection, prepared=False) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2742, in get_db_prep_value value = self.get_prep_value(value) File "/opt/horilla/horillaenv/lib/python3.10/site-packages/django/db/models/fields/__init__.py", line 2055, in get_prep_value raise e.__class__( TypeError: Field 'id' expected a number but got datetime.datetime(2024, 4, 10, 8, 28, 24, 986112, tzinfo=datetime.timezone.utc).

Environment

Priority

medium

horilla-opensource commented 1 month ago

Hi @sergej-wv , Can you share the contents of the _pms.0008_keyresult_alter_feedback_options_andmore file?

With Regards, Team Horilla

sergej-wv commented 1 month ago

Hello,

I cannot find this file inside our current installation. We updated to the latest state of the master branch and also 1.0 branch.

Best regards.

horilla-opensource commented 1 month ago

Hi @sergej-wv , Was the migrations folder removed from the apps ?

With Regards, Team Horilla

sergej-wv commented 1 month ago

No, I found other files with names starting with "0008" but not the one above.

horilla-opensource commented 1 month ago

Hi @sergej-wv , Can you share the contents of last migration file in the PMS app?

With Regards, Team Horilla

sergej-wv commented 1 month ago

Hello,

how do I check the last migration file ? There are multiple migrations folders inside other folders, like "employee" and "base". In case it is helpful, this is the current git head:

$ git show
commit 7ee91eab27acb1b18683ec8a0e7bda168c522995 (HEAD -> master)
Author: Horilla <teamhorilla@gmail.com>
Date:   Mon Mar 4 14:42:26 2024 +0530

    [UPDT] BASE: Updated objectiveDetailModal style

diff --git a/templates/index.html b/templates/index.html
[...]

Best regards.

horilla-opensource commented 1 month ago

Hi @sergej-wv , The migration files are locally generated files to update the schemas for the database when there is a change in the models. There will be separate folders for migrations in each of the installed apps. In our case, you can go pms>migrations. Inside that folder you will find several python folders, in which we need the last written file (It will be file with name structure 000*.py. The last written file will be the one highest integer value. You can see the screenshot for an example. In the screenshot the last written file will be _0006_employeeobjective_created_by_andmore.py )

Screenshot 2024-04-11 at 1 06 54 PM

With Regards, Team Horilla

sergej-wv commented 1 month ago

Hello,

this is the content of the migration with the highest number, 0007_alter_anonymousfeedback_feedback_description_and_more.py:

0007_alter_anonymousfeedback_feedback_description_and_more.py # Generated by Django 4.2.7 on 2024-03-04 09:37 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('pms', '0006_anonymousfeedback'), ] operations = [ migrations.AlterField( model_name='anonymousfeedback', name='feedback_description', field=models.TextField(blank=True, max_length=255, null=True), ), migrations.AlterField( model_name='employeekeyresult', name='key_result_description', field=models.TextField(max_length=255, null=True), ), migrations.AlterField( model_name='employeeobjective', name='objective_description', field=models.TextField(max_length=255), ), migrations.AlterField( model_name='historicalemployeekeyresult', name='key_result_description', field=models.TextField(max_length=255, null=True), ), migrations.AlterField( model_name='historicalemployeeobjective', name='objective_description', field=models.TextField(max_length=255), ), ]
horilla-opensource commented 1 month ago

Is the issue coming out on our test database or your live database?

sergej-wv commented 1 month ago

A live database is being used.

horilla-opensource commented 1 month ago

As far from the log details and the last written file we are not able to correctly point out the issue. Can we schedule a meeting with our development team where they'll be able to provide you with a solution for the same?

With Regards, Team Horilla

sergej-wv commented 1 month ago

Hello,

what can "schedule a meeting" be understood ? Was this not already passed to the developers ? Also, in case it helps, we might provide access to the installation if we get the permission.

Best regards, Sergej Kurtin

horilla-opensource commented 1 month ago

Hi @sergej-wv , Yes the development team is adding the comments. I have mentioned a one on one meeting where we can talk in person and discuss the issue. Also if you can give us the permission access to the installation we can also help you with that.

With Regards, Team Horilla