CS-GEJMERZY / VIP-Plugin

VIP plugin designed to work with CSS framework on cs2 servers.
GNU General Public License v3.0
13 stars 3 forks source link

[BUG] Unable to initialize Services database #38

Closed mstankov closed 4 months ago

mstankov commented 4 months ago

Unable to initialize databases

Players is created fine and populated as intended. Services is throwing an error:

22:11:52 [EROR] (plugin:VIP Plugin) Error while initializing database: System.Exception: Encountered exception while creating tables
 ---> System.Exception: Error executing SQL command: 
            CREATE TABLE IF NOT EXISTS Services (
            id INT PRIMARY KEY AUTO_INCREMENT,
            availability INT DEFAULT 2,
            player_id INT NOT NULL,
            start_date TIMESTAMP,
            end_date TIMESTAMP,
            flags VARCHAR(255),
            group_id VARCHAR(64),
            notes TEXT,
            FOREIGN KEY (player_id) REFERENCES Players(id)
            );
 ---> MySqlConnector.MySqlException (0x80004005): Invalid default value for 'end_date'
   at MySqlConnector.Core.ServerSession.ReceiveReplyAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 885

Don't have VS up and running but I'm guessing setting TIMESTAMP DEFAULT CURRENT_TIMESTAMP as you do with Players lastconnect would fix it. Probably some issue with the hosting provider's SQL settings regarding the default values? Not sure tbh.

HackerDevs commented 4 months ago

Hello, thank you for the report. I personally didn't find the issue with tables creation. I've added DEFAULT CURRENT_TIMESTAMP, as suggested. Please check if it solves the issue. https://github.com/CS-GEJMERZY/VIP-Plugin/actions/runs/9022705171/artifacts/1488963180

mstankov commented 4 months ago

Tried it locally - seems to be doing the job. The table was created successfully. I'm not big on databases so I might be wrong but it could be due to a specific setting on the host's database instances.

Thanks for the plugin