versx / WhMgr-UI

6 stars 15 forks source link

Settings are not saved #91

Open ZombieCorn80 opened 2 years ago

ZombieCorn80 commented 2 years ago

Whenever something is changed in the "Settings" and then the "Save" button is clicked, the settings are not saved. Of course, that's particularly stupid, because you can't turn the notifications on/off in this way. I always have to change it manually in the DB by changing the value at "staus" from "0" to "127".

versx commented 2 years ago

@ZombieCorn80 This could possibly be from the database schema not having the correct column types set. I'm able to save settings myself with my instance and confirmed the changes via database.

Could you please provide the output of the following query against your database to see what's not lining up:

SHOW CREATE TABLE subscriptions;
ZombieCorn80 commented 2 years ago

@versx subscriptions

versx commented 2 years ago

@versx subscriptions

Pretty sure the no default set for location, icon_style, and phone_numbers are making it fail.

Try:

ALTER TABLE `subscriptions` MODIFY `location` longtext DEFAULT NULL;
ALTER TABLE `subscriptions` MODIFY `icon_style` longtext DEFAULT NULL;
ALTER TABLE `subscriptions` MODIFY `phone_number` longtext DEFAULT NULL;

(might need to rename MODIFY to CHANGE)

Expected subscriptions table scheme:

CREATE TABLE `subscriptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `status` tinyint(3) unsigned NOT NULL,
  `location` longtext DEFAULT NULL,
  `icon_style` longtext DEFAULT NULL,
  `phone_number` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ZombieCorn80 commented 2 years ago

@versx Unfortunately it didn't help and I'm not entirely sure if anything was changed. In HeidiSQL it looks like this and I mean it's DEFAULT NULL, or am I wrong?! DB_1

versx commented 2 years ago

@versx Unfortunately it didn't help and I'm not entirely sure if anything was changed. In HeidiSQL it looks like this and I mean it's DEFAULT NULL, or am I wrong?! DB_1

Everything seems fine as far as I can tell, although I'm going to assume the user_name column you added yourself? Since it's set to default to NULL that shouldn't be causing issues when saving.

One thing I'd suggest trying would be to create a fresh database and run WhMgr to create the tables. Then change WhMgr-UI config to point to that new database and see if you have the same issue.

Also, is there any logs in UI when you make the changes to indicate an issue?

I remember Pokedave having this issue a while back and IIRC I think we fixed it by just creating a new database and copied the data over.

Here's the full scheme to skip a step:

CREATE TABLE `subscriptions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `status` tinyint(3) unsigned NOT NULL,
  `location` longtext DEFAULT NULL,
  `icon_style` longtext DEFAULT NULL,
  `phone_number` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `pokemon` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subscription_id` int(11) NOT NULL,
  `pokemon_id` longtext NOT NULL,
  `forms` longtext DEFAULT NULL,
  `min_cp` int(11) NOT NULL,
  `max_cp` int(11) NOT NULL DEFAULT 2147483647,
  `min_iv` int(11) NOT NULL,
  `iv_list` longtext DEFAULT NULL,
  `min_lvl` int(11) NOT NULL,
  `max_lvl` int(11) NOT NULL,
  `gender` varchar(1) NOT NULL DEFAULT '*',
  `size` tinyint(3) unsigned NOT NULL,
  `areas` longtext DEFAULT NULL,
  `location` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IX_pokemon_subscription_id` (`subscription_id`),
  CONSTRAINT `FK_pokemon_subscriptions_subscription_id` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `pvp` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subscription_id` int(11) NOT NULL,
  `pokemon_id` longtext NOT NULL,
  `forms` longtext DEFAULT NULL,
  `league` longtext NOT NULL,
  `min_rank` int(11) NOT NULL,
  `min_percent` double NOT NULL,
  `areas` longtext DEFAULT NULL,
  `location` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `gender` varchar(1) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IX_pvp_subscription_id` (`subscription_id`),
  CONSTRAINT `FK_pvp_subscriptions_subscription_id` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `raids` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subscription_id` int(11) NOT NULL,
  `pokemon_id` longtext NOT NULL,
  `forms` longtext DEFAULT NULL,
  `areas` longtext DEFAULT NULL,
  `location` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `ex_eligible` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `IX_raids_subscription_id` (`subscription_id`),
  CONSTRAINT `FK_raids_subscriptions_subscription_id` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `gyms` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subscription_id` int(11) NOT NULL,
  `name` longtext DEFAULT NULL,
  `min_level` smallint(5) unsigned NOT NULL,
  `max_level` smallint(5) unsigned NOT NULL,
  `pokemon_ids` longtext DEFAULT NULL,
  `location` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  `ex_eligible` tinyint(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `IX_gyms_subscription_id` (`subscription_id`),
  CONSTRAINT `FK_gyms_subscriptions_subscription_id` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `quests` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subscription_id` int(11) NOT NULL,
  `pokestop_name` longtext DEFAULT NULL,
  `reward` longtext DEFAULT NULL,
  `areas` longtext DEFAULT NULL,
  `location` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IX_quests_subscription_id` (`subscription_id`),
  CONSTRAINT `FK_quests_subscriptions_subscription_id` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `invasions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subscription_id` int(11) NOT NULL,
  `pokestop_name` longtext DEFAULT NULL,
  `grunt_type` longtext DEFAULT NULL,
  `reward_pokemon_id` longtext DEFAULT NULL,
  `areas` longtext DEFAULT NULL,
  `location` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IX_invasions_subscription_id` (`subscription_id`),
  CONSTRAINT `FK_invasions_subscriptions_subscription_id` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `lures` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subscription_id` int(11) NOT NULL,
  `pokestop_name` longtext DEFAULT NULL,
  `lure_type` longtext NOT NULL,
  `areas` longtext DEFAULT NULL,
  `location` longtext DEFAULT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IX_lures_subscription_id` (`subscription_id`),
  CONSTRAINT `FK_lures_subscriptions_subscription_id` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `locations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subscription_id` int(11) NOT NULL,
  `name` longtext NOT NULL,
  `distance` int(11) NOT NULL,
  `latitude` double NOT NULL,
  `longitude` double NOT NULL,
  `guild_id` bigint(20) unsigned NOT NULL,
  `user_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IX_locations_subscription_id` (`subscription_id`),
  CONSTRAINT `FK_locations_subscriptions_subscription_id` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `__EFMigrationsHistory` (
  `MigrationId` varchar(150) NOT NULL,
  `ProductVersion` varchar(32) NOT NULL,
  PRIMARY KEY (`MigrationId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO `metadata` ('MigrationId', 'ProductVersion')
VALUES
    ('20210707002802_InitialCreate', '5.0.7'),
    ('20210707043736_AddMultiRaidSubSupport', '5.0.7'),
    ('20210714054610_AddExRaidGymSubFilter', '5.0.7'),
    ('20210909003442_AddMultiInvasionSubSupport', '5.0.8'),
    ('20210909012222_AddMultiLureSubSupport', '5.0.8'),
    ('20220109043031_ModifyFormsToList', '5.0.10'),
    ('20220109043806_RenameCityToAreas', '5.0.10'),
    ('20220314014357_AddPvpGenderSubSupport', '5.0.14'),
    ('20220514090320_AddPokemonMaxCP', '5.0.14'),
    ('20220610023521_UpdateDefaultColumnValues', '5.0.14');
ZombieCorn80 commented 2 years ago

31AC6CC4-C044-4D3B-A027-3C6BAB9432A7

ZombieCorn80 commented 2 years ago

an error occurred during creation. I can create subscriptions on the website and they are also saved in the new DB, but now I get a "504 Gateway Time-out" when saving the settings. @versx

versx commented 2 years ago
__EFMigrationsHistory

Although I think you got passed it, that's my bad I had two typos I didn't catch.

- INSERT INTO `metadata` ('MigrationId', 'ProductVersion')
+ INSERT INTO `__EFMigrationsHistory`
VALUES
    ('20210707002802_InitialCreate', '5.0.7'),
    ('20210707043736_AddMultiRaidSubSupport', '5.0.7'),
    ('20210714054610_AddExRaidGymSubFilter', '5.0.7'),
    ('20210909003442_AddMultiInvasionSubSupport', '5.0.8'),
    ('20210909012222_AddMultiLureSubSupport', '5.0.8'),
    ('20220109043031_ModifyFormsToList', '5.0.10'),
    ('20220109043806_RenameCityToAreas', '5.0.10'),
    ('20220314014357_AddPvpGenderSubSupport', '5.0.14'),
    ('20220514090320_AddPokemonMaxCP', '5.0.14'),
    ('20220610023521_UpdateDefaultColumnValues', '5.0.14');
versx commented 2 years ago

an error occurred during creation. I can create subscriptions on the website and they are also saved in the new DB, but now I get a "504 Gateway Time-out" when saving the settings. @versx

Any logs in pm2 for the UI when you get the 504 timeout?