Sfoglia il codice sorgente

fixed duplicate channel bug

subDesTagesMitExtraKaese 3 anni fa
parent
commit
1ab2f5536c
2 ha cambiato i file con 5 aggiunte e 4 eliminazioni
  1. 2 2
      channel-statistics.js
  2. 3 2
      createTables.sql

+ 2 - 2
channel-statistics.js

@@ -133,8 +133,8 @@ registerPlugin({
       if (!err) {
       if (!err) {
         if(res.length > 0) {
         if(res.length > 0) {
           const id = res[0].id;
           const id = res[0].id;
-          dbc.exec("UPDATE channel SET name = ?, parentId = ?, position = ?, description = ? WHERE id = ?", 
-            remove_non_utf8(channel.name()), parentId, channel.position(), remove_non_utf8(channel.description()), id);
+          dbc.exec("UPDATE channel SET name = ?, parentId = ?, position = ?, description = ? WHERE channelId = ? AND serverId = ?",
+            remove_non_utf8(channel.name()), parentId, channel.position(), remove_non_utf8(channel.description()), channel.id(), serverId);
           cb(id);
           cb(id);
         } else {
         } else {
           dbc.exec("INSERT INTO channel (channelId, name, serverId, parentId, position, description) VALUES (?, ?, ?, ?, ?, ?)", 
           dbc.exec("INSERT INTO channel (channelId, name, serverId, parentId, position, description) VALUES (?, ?, ?, ?, ?, ?)", 

+ 3 - 2
createTables.sql

@@ -3,7 +3,7 @@
 -- https://www.phpmyadmin.net/
 -- https://www.phpmyadmin.net/
 --
 --
 -- Host: localhost:3306
 -- Host: localhost:3306
--- Erstellungszeit: 17. Okt 2021 um 00:27
+-- Erstellungszeit: 17. Okt 2021 um 13:12
 -- Server-Version: 10.3.29-MariaDB-0+deb10u1
 -- Server-Version: 10.3.29-MariaDB-0+deb10u1
 -- PHP-Version: 7.3.29-1~deb10u1
 -- PHP-Version: 7.3.29-1~deb10u1
 
 
@@ -63,7 +63,8 @@ CREATE TABLE `server` (
 -- Indizes für die Tabelle `channel`
 -- Indizes für die Tabelle `channel`
 --
 --
 ALTER TABLE `channel`
 ALTER TABLE `channel`
-  ADD PRIMARY KEY (`id`);
+  ADD PRIMARY KEY (`id`),
+  ADD UNIQUE KEY `channelId` (`channelId`,`serverId`);
 
 
 --
 --
 -- Indizes für die Tabelle `channelEvent`
 -- Indizes für die Tabelle `channelEvent`