task/3382: Harmonisera tabellnamn #6

Merged
ansv7779 merged 104 commits from task/3382 into develop 2024-11-12 13:33:44 +01:00
2 changed files with 74 additions and 3 deletions
Showing only changes of commit eea38b742f - Show all commits

View File

@ -5,13 +5,13 @@ import java.util.Objects;
@Entity @Entity
@Cacheable(true) @Cacheable(true)
@Table(name="username", uniqueConstraints={@UniqueConstraint(columnNames={"username"})}) @Table(name="user_name", uniqueConstraints={@UniqueConstraint(name = "uk_user_name", columnNames={"user_name"})})
tozh4728 marked this conversation as resolved Outdated

Username is one word, not two. User name is a user's name (John Doe) while username is their unique identifier john@doe.example.

Username is one word, not two. User name is a user's name (John Doe) while username is their unique identifier `john@doe.example`.
public class Username extends DomainObject { public class Username extends DomainObject {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@Basic(optional=false) @Column(name = "user_name", nullable = false)
tozh4728 marked this conversation as resolved Outdated

Username is one word, not two. User name is a user's name (John Doe) while username is their unique identifier john@doe.example.

Username is one word, not two. User name is a user's name (John Doe) while username is their unique identifier `john@doe.example`.
private String username; private String username;
@ManyToOne(optional=false) @ManyToOne(optional=false)

View File

@ -599,4 +599,75 @@ alter table `notification_delivery_configuration`
foreign key (user_id) foreign key (user_id)
references user(id) references user(id)
on delete cascade on delete cascade
on update cascade; on update cascade;
-- table: username
alter table `username` drop foreign key `FK_17moq4bksxe30ihucce3jovdc`;
alter table `username` drop key `FK_17moq4bksxe30ihucce3jovdc`;
alter table `username` drop key `username_must_be_unique`;
rename table `username` to `user_name`;
alter table `user_name` rename column `username` to `user_name`;
alter table `user_name` add constraint uk_user_name unique(user_name);
alter table `user_name`
add constraint fk_user_name_user_id
foreign key (user_id)
references user(id)
on delete cascade
on update cascade;
/* the mess with ProjectType
SQL query for FK-to:
select table_name, column_name, referenced_table_name, referenced_column_name
from key_column_usage
where table_schema = 'tozh4728' and
referenced_table_name = 'ProjectType';
select referenced_table_name, count(*) as c
from key_column_usage
where table_schema = 'tozh4728' and
referenced_table_name is not null
group by referenced_table_name order by c desc;
SQL Query for FK-from
select table_name, column_name, referenced_table_name, referenced_column_name
from key_column_usage
where referenced_table_name is not null and table_name = 'user'
order by table_name;
A. Drop FK from following tables
1. ExternalResource
2. project_type_settings
3. project_type_project_modules
4. projectPartner
5. target
6. checklist_template_ProjectType
7. grading_report_template
8. milestone_activity_template_ProjectType
9. ApplicationPeriodProjectType
10. user_profile_ProjectType
11. idea
12. project
B. Fix table ProjectType
C. Recreate FK for following tables without fixing the table.
1. idea
2. project
*/