Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 74dc62a

Browse files
committed
feat: update punishment tables to use CloudPlayer references and rename tables for consistency
1 parent 57085be commit 74dc62a

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/GenerateExposedMigrationScript.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ fun main() {
1616
MutePunishmentNoteTable,
1717
WarnPunishmentNoteTable,
1818
WhitelistTable,
19-
scriptName = "V7__add_whitelist_table",
19+
scriptName = "V8__change_tables_add_cloud_player_references",
2020
)
2121
}

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/player/db/exposed/CloudPlayerTables.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dev.slne.surf.cloud.api.server.exposed.table.AuditableLongIdTable
77
import org.jetbrains.exposed.sql.ReferenceOption
88
import java.net.Inet4Address
99

10-
object CloudPlayerTable : AuditableLongIdTable("cloud_player") {
10+
object CloudPlayerTable : AuditableLongIdTable("cloud_players") {
1111
val uuid = nativeUuid("uuid").uniqueIndex()
1212
val lastServer = char("last_server", 255).nullable()
1313
val lastSeen = zonedDateTime("last_seen").nullable()
@@ -19,7 +19,7 @@ object CloudPlayerTable : AuditableLongIdTable("cloud_player") {
1919
.nullable()
2020
}
2121

22-
object CloudPlayerNameHistoryTable : AuditableLongIdTable("cloud_player_name_history") {
22+
object CloudPlayerNameHistoryTable : AuditableLongIdTable("cloud_player_name_histories") {
2323
val name = char("name", 16)
2424
val player = reference(
2525
"cloud_player_id",

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/player/db/exposed/punishment/table/AbstractPunishmentTable.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@ import dev.slne.surf.cloud.api.server.exposed.table.AuditableLongIdTable
55

66
abstract class AbstractPunishmentTable(name: String) : AuditableLongIdTable(name) {
77
val punishmentId = char("punishment_id", 8).uniqueIndex()
8-
val punishedUuid = nativeUuid("punished_uuid")
9-
val issuerUuid = nativeUuid("issuer_uuid").nullable()
8+
val parentPunishment = reference(
9+
"parent_punishment_id",
10+
this,
11+
onDelete = ReferenceOption.CASCADE,
12+
onUpdate = ReferenceOption.CASCADE
13+
).nullable()
14+
val punishedPlayer = reference(
15+
"cloud_player_id",
16+
CloudPlayerTable,
17+
onDelete = ReferenceOption.CASCADE,
18+
onUpdate = ReferenceOption.CASCADE
19+
)
20+
val issuerPlayer = reference(
21+
"issuer_id",
22+
CloudPlayerTable,
23+
onDelete = ReferenceOption.SET_NULL,
24+
onUpdate = ReferenceOption.SET_NULL
25+
).nullable()
1026
val reason = largeText("reason").nullable()
11-
12-
init {
13-
index("idx_punished_uuid", false, punishedUuid)
14-
}
1527
}

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/player/db/exposed/punishment/table/AbstractUnpunishableExpirablePunishmentTable.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ abstract class AbstractUnpunishableExpirablePunishmentTable(name: String) :
77
AbstractPunishmentTable(name) {
88
val unpunished = bool("unpunished").default(false)
99
val unpunishedDate = zonedDateTime("unpunished_date").nullable().default(null)
10-
val unpunisherUuid = nativeUuid("unpunisher_uuid").nullable().default(null)
10+
val unpunisherPlayer = reference(
11+
"unpunisher_id",
12+
CloudPlayerTable,
13+
onDelete = ReferenceOption.CASCADE,
14+
onUpdate = ReferenceOption.CASCADE
15+
).nullable().default(null)
1116
val expirationDate = zonedDateTime("expiration_date").nullable().default(null)
1217
val permanent = bool("permanent").default(false)
1318

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/player/db/exposed/whitelist/WhitelistTable.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import org.jetbrains.exposed.sql.ReferenceOption
77
import org.jetbrains.exposed.sql.and
88
import org.jetbrains.exposed.sql.or
99

10-
object WhitelistTable : AuditableLongIdTable("whitelist") {
11-
val uuid = nativeUuid("uuid").index()
10+
object WhitelistTable : AuditableLongIdTable("whitelists") {
1211
val blocked = bool("blocked").default(false)
1312
val group = varchar("group", 255).nullable()
1413
val serverName = varchar("server_name", 255).nullable()
@@ -25,6 +24,6 @@ object WhitelistTable : AuditableLongIdTable("whitelist") {
2524
}
2625

2726
uniqueIndex(uuid, group)
28-
uniqueIndex(uuid, serverName,)
27+
uniqueIndex(uuid, serverName)
2928
}
3029
}

0 commit comments

Comments
 (0)