Skip to content

Commit

Permalink
Updated sql index and constraint names to match convention
Browse files Browse the repository at this point in the history
  • Loading branch information
maallen committed Aug 15, 2023
1 parent 436141f commit 1c2581a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import org.joda.time.DateTime;

/** Entity that stores the checksum of a translated file downloaded via a third party sync. */
@Entity
@Table(
name = "third_party_sync_file_checksum",
indexes = {
@Index(
name = "I__THIRD_PARTY__CHECKSUM__REPOSITORY_ID__FILE_NAME__LOCALE_ID",
name = "I__TP_FILE_CHECKSUM__REPO_ID__LOCALE_ID__FILE_NAME",
columnList = "repository_id, locale_id, file_name",
unique = true),
})
Expand All @@ -33,11 +31,6 @@ public ThirdPartyFileChecksum(
this.md5 = md5;
}

@PreUpdate
public void preUpdate() {
lastModifiedDate = new DateTime();
}

public ThirdPartyFileChecksumCompositeId getThirdPartyFileChecksumCompositeId() {
return thirdPartyFileChecksumCompositeId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ThirdPartyFileChecksumCompositeId implements Serializable {
@ManyToOne(optional = false)
@JoinColumn(
name = "repository_id",
foreignKey = @ForeignKey(name = "FK__THIRD_PARTY_CHECKSUM__REPO__ID"))
foreignKey = @ForeignKey(name = "FK__TP_FILE_CHECKSUM__REPO__ID"))
private Repository repository;

@Column(name = "file_name")
Expand All @@ -22,7 +22,7 @@ public class ThirdPartyFileChecksumCompositeId implements Serializable {
@ManyToOne(optional = false)
@JoinColumn(
name = "locale_id",
foreignKey = @ForeignKey(name = "FK__THIRD_PARTY_CHECKSUM__LOCALE__ID"))
foreignKey = @ForeignKey(name = "FK__TP_FILE_CHECKSUM__LOCALE__ID"))
private Locale locale;

public ThirdPartyFileChecksumCompositeId() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ create table third_party_sync_file_checksum (
last_modified_date datetime,
primary key (id)
);
alter table third_party_sync_file_checksum add constraint FK__THIRD_PARTY_CHECKSUM__REPO__ID foreign key (repository_id) references repository (id);
alter table third_party_sync_file_checksum add constraint FK__THIRD_PARTY_CHECKSUM__LOCALE__ID foreign key (locale_id) references locale (id);
create unique index I__THIRD_PARTY__CHECKSUM__REPOSITORY_ID__FILE_NAME__LOCALE_ID on third_party_sync_file_checksum(repository_id, locale_id, file_name);
alter table third_party_sync_file_checksum add constraint FK__TP_FILE_CHECKSUM__REPO__ID foreign key (repository_id) references repository (id);
alter table third_party_sync_file_checksum add constraint FK__TP_FILE_CHECKSUM__LOCALE__ID foreign key (locale_id) references locale (id);
create unique index I__TP_FILE_CHECKSUM__REPO_ID__LOCALE_ID__FILE_NAME on third_party_sync_file_checksum(repository_id, locale_id, file_name);

0 comments on commit 1c2581a

Please sign in to comment.