Compare commits

...

3 commits

Author SHA1 Message Date
0afe1e5b5b Updated Globals
switched from Context.ensure_tables() to Context.run_migrations()
2026-03-06 22:44:23 -06:00
1de7baf717 Created Migrations for Database
Created migrations for database to allow modification in the future,
without loosing data.
2026-03-06 22:44:02 -06:00
b0ad37eda2 Updated Models
Updated models to use new formatting for Types namespace.
2026-03-06 22:43:43 -06:00
8 changed files with 113 additions and 5 deletions

View file

@ -16,7 +16,11 @@ func _ready() -> void:
context.setup() context.setup()
context.open_db("user://overlay.db") context.open_db("user://overlay.db")
context.ensure_tables() # Method one, just create all tables, prevents alterations to existing tables.
#context.ensure_tables()
# Method two, use migrations to handle setting up database tables, ensuring that
# tables can be modified in the future
context.run_migrations()
if FileAccess.file_exists("user://settings.tres"): if FileAccess.file_exists("user://settings.tres"):
settings = load("user://settings.tres") settings = load("user://settings.tres")
else: else:

View file

@ -32,5 +32,5 @@ enum ChatterLevel
static func _setup() -> void: static func _setup() -> void:
set_table_name(Chatter, "chatters") set_table_name(Chatter, "chatters")
set_column_flags(Chatter, "id", Flags.PRIMARY_KEY|Flags.AUTO_INCREMENT|Flags.NOT_NULL) set_column_flags(Chatter, "id", Types.Flags.PRIMARY_KEY|Types.Flags.AUTO_INCREMENT|Types.Flags.NOT_NULL)
set_column_flags(Chatter, "twitch_id", Flags.NOT_NULL) set_column_flags(Chatter, "twitch_id", Types.Flags.NOT_NULL)

View file

@ -27,7 +27,7 @@ var comments_url: String:
static func _setup() -> void: static func _setup() -> void:
set_table_name(ItchIOAppData, "itch_apps") set_table_name(ItchIOAppData, "itch_apps")
set_column_flags(ItchIOAppData, "id", Flags.PRIMARY_KEY|Flags.NOT_NULL) set_column_flags(ItchIOAppData, "id", Types.Flags.PRIMARY_KEY|Types.Flags.NOT_NULL)
ignore_column(ItchIOAppData, "is_free") ignore_column(ItchIOAppData, "is_free")
ignore_column(ItchIOAppData, "url") ignore_column(ItchIOAppData, "url")
ignore_column(ItchIOAppData, "comments_url") ignore_column(ItchIOAppData, "comments_url")

View file

@ -74,7 +74,7 @@ var utm_url: String:
static func _setup() -> void: static func _setup() -> void:
set_table_name(SteamAppData, "steam_apps") set_table_name(SteamAppData, "steam_apps")
set_column_flags(SteamAppData, "steam_app_id", Flags.PRIMARY_KEY|Flags.NOT_NULL) set_column_flags(SteamAppData, "steam_app_id", Types.Flags.PRIMARY_KEY|Types.Flags.NOT_NULL)
ignore_column(SteamAppData, "detailed_description_bbcode") ignore_column(SteamAppData, "detailed_description_bbcode")
ignore_column(SteamAppData, "short_url") ignore_column(SteamAppData, "short_url")
ignore_column(SteamAppData, "seo_url") ignore_column(SteamAppData, "seo_url")

34
migrations/001_initial.gd Normal file
View file

@ -0,0 +1,34 @@
extends Migration
func _up() -> void:
var table: Migration.TableDef
# Create Table chatters
table = create_table("chatters")
table.add_column("id", Types.DataType.INT, Types.Flags.PRIMARY_KEY | Types.Flags.NOT_NULL, {})
table.add_column("twitch_id", Types.DataType.STRING, Types.Flags.NOT_NULL, {})
table.add_column("nickname", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("known_engine", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("steam_games", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("itch_games", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("urls", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("is_indie_game_dev", Types.DataType.BOOL, Types.Flags.NONE, {})
table.add_column("is_on_team", Types.DataType.BOOL, Types.Flags.NONE, {})
table.add_column("level", Types.DataType.INT, Types.Flags.NONE, {})
table.add_column("auto_shoutout", Types.DataType.BOOL, Types.Flags.NONE, {})
table.add_column("shoutout_as_devteam", Types.DataType.BOOL, Types.Flags.NONE, {})
table.add_column("notes", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("scores", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("extra_data", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("first_seen", Types.DataType.REAL, Types.Flags.NONE, {})
table.add_column("last_seen", Types.DataType.REAL, Types.Flags.NONE, {})
func _down() -> void:
# Drop Table chatters
drop_table("chatters")

View file

@ -0,0 +1 @@
uid://byvn338f077hm

View file

@ -0,0 +1,68 @@
extends Migration
func _up() -> void:
# Insert upgrade instructions to modify database structure below
# Create Table itch_apps
var table := create_table("itch_apps")
table.add_column("id", Types.DataType.INT, Types.Flags.PRIMARY_KEY | Types.Flags.NOT_NULL, {})
table.add_column("title", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("authors", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("tags", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("links", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("cover_image", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("price", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("description", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("screenshots_thumbnails", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("screenshots_full", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("added", Types.DataType.REAL, Types.Flags.NONE, {})
# Create Table steam_apps
table = create_table("steam_apps")
table.add_column("steam_app_id", Types.DataType.INT, Types.Flags.PRIMARY_KEY | Types.Flags.NOT_NULL, {})
table.add_column("type", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("name", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("required_age", Types.DataType.INT, Types.Flags.NONE, {})
table.add_column("is_free", Types.DataType.BOOL, Types.Flags.NONE, {})
table.add_column("short_description", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("detailed_description", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("header_image", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("capsule_image", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("capsule_imagev5", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("website", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("developers", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("publishers", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("platforms", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("genres", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("release_date", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("screenshots_full", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("screenshots_thumbs", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("trailer_mp4", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("trailer_webm", Types.DataType.DICTIONARY, Types.Flags.NONE, {})
table.add_column("trailer_thumbnail", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("price_currency", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("price_initial", Types.DataType.INT, Types.Flags.NONE, {})
table.add_column("price_final", Types.DataType.INT, Types.Flags.NONE, {})
table.add_column("price_discount_percent", Types.DataType.INT, Types.Flags.NONE, {})
table.add_column("price_initial_formatted", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("price_final_formatted", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("categories", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("dlc", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("packages", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("total_achievements", Types.DataType.INT, Types.Flags.NONE, {})
table.add_column("highlighted_achievements", Types.DataType.ARRAY, Types.Flags.NONE, {})
table.add_column("pc_requirements", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("mac_requirements", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("linux_requirements", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("support_email", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("support_url", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("background_image", Types.DataType.STRING, Types.Flags.NONE, {})
table.add_column("background_image_raw", Types.DataType.STRING, Types.Flags.NONE, {})
pass
func _down() -> void:
# Insert downgrade instructions to modify database structure below.
# Drop Table itch_apps
drop_table("itch_apps")
# Drop Table steam_apps
drop_table("steam_apps")

View file

@ -0,0 +1 @@
uid://dkoc1y0bjblfw