ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Gromulus/models.py
Revision: 988
Committed: Sun Mar 8 04:15:07 2026 UTC (2 weeks, 6 days ago) by nino.borges
Content type: text/x-python
File size: 3962 byte(s)
Log Message:
Added a database dictionary markdown file which attempts to describe at a highlevel the database, tables, fields and the reason for these. also updaed the models.py file to reflect the updated database, since it was so out of date.  I'm currently not using it beyond documenting the schema.  also added a Projet Guidelines file and lessons learned file.  These are my attempt at tryiing out spec-driven development.  Projectguidelines is the core guide that will act as the source of truth of the application.

File Contents

# Content
1 """SQLAlchemy schema definitions for the current Gromulus SQLite database.
2
3 This module is intentionally written with SQLAlchemy Core ``Table`` objects
4 instead of ORM declarative classes so it can represent tables that do not
5 have primary keys (for example ``no_intro_main`` and ``tosec_main``).
6 """
7
8 from sqlalchemy import (
9 Column,
10 ForeignKey,
11 Index,
12 Integer,
13 MetaData,
14 Table,
15 Text,
16 UniqueConstraint,
17 )
18
19
20 metadata = MetaData()
21
22
23 main_app_system = Table(
24 "main_app_system",
25 metadata,
26 Column("id", Integer, primary_key=True, autoincrement=True, nullable=False),
27 Column("name", Text),
28 Column("short_name", Text),
29 Column("relative_file_path", Text),
30 )
31
32
33 main_app = Table(
34 "main_app",
35 metadata,
36 Column("id", Integer, primary_key=True, autoincrement=True, nullable=False),
37 Column("game_name", Text),
38 Column("game_name_scraped", Text),
39 Column("container_file_name", Text),
40 Column("description", Text),
41 Column("description_scraped", Text),
42 Column("system_console", Integer),
43 Column("system_console_scraped", Text),
44 Column("path_to_screenshot_box", Text),
45 Column("path_to_screenshot_title", Text),
46 Column("path_to_screenshot_ingame", Text),
47 Column("path_to_video", Text),
48 Column("user_notes", Text),
49 Column("container_md5_hash", Text),
50 Column("version", Text),
51 )
52
53
54 main_app_file_hash = Table(
55 "main_app_file_hash",
56 metadata,
57 Column("id", Integer, primary_key=True, autoincrement=True, nullable=False),
58 Column("file_name", Text),
59 Column("file_md5_hash", Text),
60 Column("container_file_id", Integer, ForeignKey("main_app.id"), nullable=False),
61 )
62
63
64 no_intro_system = Table(
65 "no_intro_system",
66 metadata,
67 Column("id", Integer, primary_key=True, nullable=False),
68 Column("name", Text),
69 Column("description", Text),
70 Column("dat_version", Text),
71 )
72
73
74 no_intro_main = Table(
75 "no_intro_main",
76 metadata,
77 Column("game_name", Text),
78 Column("no_intro_id", Text),
79 Column("clone_of_id", Text),
80 Column("description", Text),
81 Column("rom_name", Text),
82 Column("crc", Text),
83 Column("md5", Text),
84 Column("sha1", Text),
85 Column("sha256", Text),
86 Column("status", Text),
87 Column("no_intro_system_id", Integer, ForeignKey("no_intro_system.id"), nullable=False),
88 Column("app_system_id", Integer),
89 )
90
91
92 tosec_main = Table(
93 "tosec_main",
94 metadata,
95 Column("game_name", Text),
96 Column("description", Text),
97 Column("rom_name", Text),
98 Column("crc", Text),
99 Column("md5", Text),
100 Column("sha1", Text),
101 Column("system_id", Integer, ForeignKey("no_intro_system.id"), nullable=False),
102 Column("app_system_id", Integer),
103 )
104
105
106 dat_import_history = Table(
107 "dat_import_history",
108 metadata,
109 Column("id", Integer, primary_key=True, autoincrement=True),
110 Column("app_system_id", Integer, ForeignKey("main_app_system.id"), nullable=False),
111 Column("source", Text, nullable=False),
112 Column("dat_name", Text),
113 Column("dat_description", Text),
114 Column("dat_version", Text),
115 Column("imported_at", Text, nullable=False),
116 Column("entry_count", Integer, nullable=False, default=0),
117 UniqueConstraint("app_system_id", "source", name="uq_dat_import_history_system_source"),
118 )
119
120
121 Index("idx_main_app_md5", main_app.c.container_md5_hash)
122 Index("idx_main_app_system", main_app.c.system_console)
123 Index("idx_no_intro_md5", no_intro_main.c.md5)
124 Index("idx_tosec_md5", tosec_main.c.md5)
125 Index("idx_no_intro_system_md5", no_intro_main.c.app_system_id, no_intro_main.c.md5)
126 Index("idx_tosec_system_md5", tosec_main.c.app_system_id, tosec_main.c.md5)
127 Index("idx_dat_import_system_source", dat_import_history.c.app_system_id, dat_import_history.c.source)
128
129
130 __all__ = [
131 "metadata",
132 "main_app_system",
133 "main_app",
134 "main_app_file_hash",
135 "no_intro_system",
136 "no_intro_main",
137 "tosec_main",
138 "dat_import_history",
139 ]