Open-Assistant icon indicating copy to clipboard operation
Open-Assistant copied to clipboard

Rename database objects/models

Open andreaskoepf opened this issue 2 years ago • 5 comments

With the latest planning iteration (see YK's presentation) some object-names were changed. To reduce confusion the naming should be updated throughout the system (it is early enough to do this breaking change).

Old New
person user
post message
post_reaction message_reaction
thread message_tree
work_package task

andreaskoepf avatar Dec 28 '22 16:12 andreaskoepf

Hi ! I started to work on this. However, I have a few questions :

Do you want to only modify these or should we also edit tables such as person_stats to user_stats ? Also, I suppose it would also be better to update PostReaction class in post_reaction.py to MessageReaction with file name message_reaction.py, right ?

Thank you.

alexandrelefourner avatar Dec 28 '22 18:12 alexandrelefourner

Do you want to only modify these or should we also edit tables such as person_stats to user_stats ?

Yes, exactly all existing tables/models/columns etc. should be adapted, for example:

table: person_stats -> user_stats column: person_id -> user_id model: PersonStats -> UserStates filename: person_stats.py -> user_stats.py

index names, e.g. ix_person_username -> ix_user_username

Also, I suppose it would also be better to update PostReaction class in post_reaction.py to MessageReaction with file name message_reaction.py, right ?

yes,exactly!

andreaskoepf avatar Dec 28 '22 18:12 andreaskoepf

If alembic revision --autogenerate -m rename_database_objects doesn't generate the correct code for the payload-JSONB columns please look in the old migration scripts and replace what alembic generated by something like sa.Column("payload", JSONB(astext_type=sa.Text()), nullable=False) ...

andreaskoepf avatar Dec 28 '22 18:12 andreaskoepf

@alexandrelefourner just saw there is #115 which should be merged first...

andreaskoepf avatar Dec 28 '22 19:12 andreaskoepf

@alexandrelefourner Suggestion: I think it would be best to do the renaming in more than one step, like starting frist with Person->User as a single PR and them working forward .. if we try everything at once it will probably create a lot of conflicts. What do you think? :-) This renaming is unfortunately/naturally affecting a lot of other code.

andreaskoepf avatar Dec 28 '22 21:12 andreaskoepf