AR-Development / PersistentEmpires-OpenSourced

GNU Affero General Public License v3.0
4 stars 19 forks source link

Updated Inventories to use Primary Key. #65

Closed Heavybob closed 4 months ago

Heavybob commented 4 months ago

This change simplifies inventories by setting InventoryId as the primary key. Instead of saying PlayerInventory, we set the InventoryId for those entries to the PlayerId. We're also removing the PlayerId column from the table as its no longer needed. To obtain if an entry is a player inventory, we still have the IsPlayerInventory bool.

This change is a stepping stone towards improved bulk updating of inventories as the current implementation updates all inventories one at a time rather than all at once.

This change has been tested and works.

Heavybob commented 4 months ago

This change modifies the Inventories table. To ensure compatability with your existing db, you'll need to run the following.

UPDATE Inventories SET InventoryId = PlayerId WHERE IsPlayerInventory = 1;


Drop Id, drop PlayerId, set InventoryId as Primary Key.

Heavybob commented 4 months ago

Added a hotfix to resolve creation. This should be good to merge now.

Heavybob commented 4 months ago

image image Here is a picture of the db changes.