mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-24 13:44:33 +00:00
[AB-161] fixed composite foreign keys for multiple tables
This commit is contained in:
@@ -103,7 +103,7 @@ public class SuggestionServiceBean implements SuggestionService {
|
||||
Long channelId = suggestion.getChannel().getId();
|
||||
Long originalMessageId = suggestion.getMessageId();
|
||||
Long serverId = suggestion.getServer().getId();
|
||||
log.info("Updated posted suggestion {} in server {}.", suggestion.getId(), suggestion.getServer().getId());
|
||||
log.info("Updated posted suggestion {} in server {}.", suggestion.getSuggestionId().getId(), suggestion.getServer().getId());
|
||||
|
||||
suggestionLog.setOriginalChannelId(channelId);
|
||||
suggestionLog.setOriginalMessageId(originalMessageId);
|
||||
@@ -112,7 +112,7 @@ public class SuggestionServiceBean implements SuggestionService {
|
||||
TextChannel textChannelById = botService.getTextChannelFromServer(serverId, channelId);
|
||||
CompletableFuture<Member> memberById = botService.getMemberInServerAsync(serverId, suggester.getUserReference().getId());
|
||||
suggestionLog.setState(suggestion.getState());
|
||||
suggestionLog.setSuggestionId(suggestion.getId());
|
||||
suggestionLog.setSuggestionId(suggestion.getSuggestionId().getId());
|
||||
CompletableFuture<Void> finalFuture = new CompletableFuture<>();
|
||||
memberById.whenComplete((member, throwable) -> {
|
||||
if(throwable == null) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.abstracto.utility.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.ServerSpecificId;
|
||||
import dev.sheldan.abstracto.core.service.management.ChannelManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||
@@ -47,7 +48,7 @@ public class SuggestionManagementServiceBean implements SuggestionManagementServ
|
||||
.builder()
|
||||
.state(SuggestionState.NEW)
|
||||
.suggester(suggester)
|
||||
.id(suggestionId)
|
||||
.suggestionId(new ServerSpecificId(suggester.getServerReference().getId(), suggestionId))
|
||||
.server(suggester.getServerReference())
|
||||
.suggestionDate(Instant.now())
|
||||
.channel(channel)
|
||||
@@ -68,7 +69,7 @@ public class SuggestionManagementServiceBean implements SuggestionManagementServ
|
||||
@Override
|
||||
public void setSuggestionState(Suggestion suggestion, SuggestionState newState) {
|
||||
suggestion.setState(newState);
|
||||
log.info("Setting suggestion {} to state {}.", suggestion.getId(), newState);
|
||||
log.info("Setting suggestion {} in server {} to state {}.", suggestion.getSuggestionId().getId(), suggestion.getSuggestionId().getServerId(), newState);
|
||||
suggestionRepository.save(suggestion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@
|
||||
http://www.liquibase.org/xml/ns/pro ../../dbchangelog-3.8.xsd" >
|
||||
<changeSet author="Sheldan" id="suggestion-table">
|
||||
<createTable tableName="suggestion">
|
||||
<column autoIncrement="true" name="id" type="BIGINT">
|
||||
<constraints nullable="false" primaryKey="true" primaryKeyName="suggestion_pkey"/>
|
||||
</column>
|
||||
<column autoIncrement="true" name="id" type="BIGINT"/>
|
||||
<column name="created" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||
<column name="message_id" type="BIGINT"/>
|
||||
<column name="state" type="VARCHAR(255)"/>
|
||||
@@ -22,6 +20,7 @@
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</createTable>
|
||||
<addPrimaryKey columnNames="server_id, id" tableName="suggestion" constraintName="pk_suggestion" validate="true"/>
|
||||
</changeSet>
|
||||
<changeSet author="Sheldan" id="suggestion-fk_suggestion_channel">
|
||||
<addForeignKeyConstraint baseColumnNames="channel_id" baseTableName="suggestion" constraintName="fk_suggestion_channel" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="channel" validate="true"/>
|
||||
|
||||
Reference in New Issue
Block a user