ultima-scraper-db-archive 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ultima_scraper_db_archive-0.2.0/.gitignore +13 -0
- ultima_scraper_db_archive-0.2.0/.python-version +1 -0
- ultima_scraper_db_archive-0.2.0/LICENSE +21 -0
- ultima_scraper_db_archive-0.2.0/PKG-INFO +58 -0
- ultima_scraper_db_archive-0.2.0/README.md +38 -0
- ultima_scraper_db_archive-0.2.0/pyproject.toml +62 -0
- ultima_scraper_db_archive-0.2.0/tests/test_migration_cli.py +123 -0
- ultima_scraper_db_archive-0.2.0/tests/test_module.py +64 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/__init__.py +98 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/_legacy_sqlite_models.py +121 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/alembic_support.py +19 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/crypto.py +179 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/databases/ultima_archive/schemas/templates/postgres_site.py +1968 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/execution_models.py +312 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/favourites_alembic.py +43 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/favourites_migration.py +330 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/favourites_models.py +63 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/global_db.py +544 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/history_alembic.py +44 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migration_cli.py +273 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/README +1 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/env.py +242 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/script.py.mako +28 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/0614b9710fa1_add_ai_assisted_and_verified_to_user_.py +58 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/1b9e08940bc5_startup_autogen_20260308_213709.py +52 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/21a95ba68935_add_orders_to_management_2.py +125 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/2fca07530bd0_startup_autogen_20260303_093333.py +80 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/35a2cb48418e_drop_data_migration_tables.py +116 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/50d23ca8a8cd_startup_autogen_20260302_205238.py +29 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/52aabfd5b7a9_startup_autogen_20260804_072522.py +48 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/52ae3b2424d1_startup_autogen_20260225_130555.py +97 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/581b84bca56b_startup_autogen_20260224_030920.py +237 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/5d21dc512ae1_add_liked_and_duration.py +42 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/6f4b2e9a17c0_index_job_receipt_deletion.py +39 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/70291d5cc215_startup_autogen_20260224_055856.py +54 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/7771050369ea_startup_autogen_20260224_031952.py +31 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/7a2d9c4e1f80_add_search_loadouts_and_repair_runtime_sequences.py +145 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/7f3bb03678e1_startup_autogen_20260302_210630.py +28 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/86b0f35fafff_startup_autogen_20260307_145304.py +210 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/870ab3e75443_startup_autogen_20260306_111904.py +60 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/88dddeb4538e_startup_autogen_20261013_180604.py +40 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/8b3e0d5a2c91_unique_config_authority.py +29 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/9c6b7f4e2a11_rebuild_auth_and_media_urls_user_id_fk.py +304 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/9e7c3a1d6b20_narrow_execution_queue.py +79 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a0f7d3c6e921_add_durable_mps_manifests.py +77 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a2ce87f67ef9_startup_autogen_20260224_033145.py +31 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a43f7c9d2e61_avoid_redundant_history_identity_reads.py +100 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a4b8e19f23c0_add_statistics_user_and_content_breakdowns.py +44 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a4c1e7d93b20_add_cluster_clients.py +87 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a4e7c2d91b38_index_job_task_errors.py +38 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a693acda9c21_add_orders_to_management.py +28 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a6d901fe7823_index_execution_deletion.py +20 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a7c3d1e5f290_add_composite_indexes_for_query_perf.py +65 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a84df9201c76_partition_execution_mutations_by_run.py +73 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/a92e10b6f3d8_add_source_identity_observations.py +31 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/b1f0f249d551_add_daily_statistics_snapshots.py +77 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/b4f2a1c9e8d3_add_job_task_message_and_result.py +40 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/b72a91cd408e_merge_mutation_partitions_and_plugins.py +13 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/b7c41e9a2d58_runtime_role_partition_ddl.py +118 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/b8f203de9147_merge_execution_deletion_and_user_info.py +18 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/ba4ce359afb9_startup_autogen_20260920_201812.py +120 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/baa73c9d688e_retire_low_value_profile_indexes.py +273 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/bd61e4a92f07_add_database_write_receipts.py +36 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/bfcc94d08ef5_startup_autogen_20260302_185746.py +105 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/bfd28f1b62e7_startup_autogen_20261023_201256.py +31 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c3e9f17a5d48_align_settings_and_websites_with_models.py +71 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c4a5f16d7e2b_make_bought_content_buyer_links_unique.py +106 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c5f2a8e17d49_tune_execution_queue_maintenance.py +37 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c79e2b4a185d_add_task_media_selections.py +73 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c7b3857c294c_add_site_external_ids.py +56 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c7d2e84a19b6_index_execution_claim_order.py +26 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c8a3e5f71d26_runtime_role_history_truncate.py +70 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c92ea6407b31_partition_all_job_history.py +208 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/c9d4e8f2a6b1_add_filepath_lookup_index.py +38 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/ce84a19f027b_add_unified_favourites.py +45 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d1e30a7b9462_merge_all_history_partitions.py +13 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d2a70c16f493_add_plugin_runtime.py +306 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d2c4f71a6b90_add_statistics_inventory_metrics.py +47 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d2e9b4c7a1f3_add_backend_peers.py +48 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d4518195deef_initial_migration.py +1786 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d5e1a7c39b42_trusted_mps_task_identity.py +112 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d613ac49e82b_add_mps_task_definitions.py +55 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d693ae680246_merge_bought_content_uniqueness_with_.py +26 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d8f4b2a19c60_favourite_integer_ids_and_timestamps.py +82 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/d8f4c2a9e631_add_mass_message_text_search_indexes.py +48 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/de82a96c410f_remove_verified_duplicate_indexes.py +190 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e25ac8106df4_add_mps_retry_checkpoints.py +33 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e29a5f9a7c41_add_post_and_message_links_to_bought_content.py +122 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e3f1a2b4c5d6_add_profile_type_sexual_content_partner_identity.py +57 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e4d7a8b9c0f1_add_user_info_description_trgm_indexes.py +66 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e5b72c1a09f4_add_import_provenance.py +123 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e6b2d8f41a73_add_cluster_identity.py +50 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e761bc24a908_add_write_receipt_retention.py +37 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e8c608daf25e_startup_autogen_20260326_093519.py +42 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/e9a62c7138bf_cover_filtered_performer_queries.py +130 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/f14c08a932de_add_canonical_task_user_id.py +25 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/f17b9e204ca6_add_ordinary_job_inputs.py +23 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/f2c4e8a1b9d7_add_websites_table_to_site_schemas.py +50 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/f3c81d2a6e57_index_execution_outbox_sequence.py +47 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/f4e1d8b7c6a2_add_content_mentions.py +82 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/f6a1c8e29b47_register_site_sort_indexes.py +118 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/f6b83a9021c4_add_execution_ledger.py +46 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic/versions/f83ad126b905_merge_receipt_retention_and_plugins.py +13 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/migrations/alembic.ini +149 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/module.py +95 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/plugin_models.py +286 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/pool_watch.py +145 -0
- ultima_scraper_db_archive-0.2.0/ultima_scraper_db_archive/site.py +374 -0
- ultima_scraper_db_archive-0.2.0/uv.lock +1488 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.14
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 UltimaScraper Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ultima-scraper-db-archive
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Archive database module hosted by the UltimaScraperDB runtime
|
|
5
|
+
Project-URL: Homepage, https://github.com/UltimaHoarder/UltimaScraperDBArchive
|
|
6
|
+
Project-URL: Repository, https://github.com/UltimaHoarder/UltimaScraperDBArchive
|
|
7
|
+
Project-URL: Issues, https://github.com/UltimaHoarder/UltimaScraperDBArchive/issues
|
|
8
|
+
Author-email: UltimaHoarder <21285176+UltimaHoarder@users.noreply.github.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Python: <3.15,>=3.14
|
|
12
|
+
Requires-Dist: alembic<2,>=1.14
|
|
13
|
+
Requires-Dist: cryptography<51,>=50
|
|
14
|
+
Requires-Dist: psycopg[binary]<4,>=3.3
|
|
15
|
+
Requires-Dist: sqlmodel<1,>=0.0.24
|
|
16
|
+
Requires-Dist: ultima-scraper-api<4,>=3.0.0b5
|
|
17
|
+
Requires-Dist: ultima-scraper-core<1,>=0.1
|
|
18
|
+
Requires-Dist: ultima-scraper-db<1,>=0.5
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# UltimaScraperDBArchive
|
|
22
|
+
|
|
23
|
+
UltimaScraperDBArchive is the archive database module hosted by the domain-neutral
|
|
24
|
+
`ultima-scraper-db` runtime. It owns archive models and constructs `ArchiveAPI`;
|
|
25
|
+
it does not own engine or session lifecycle.
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from ultima_scraper_db import DatabaseConfig, DatabaseManager
|
|
29
|
+
from ultima_scraper_db_archive import USDBArchiveModule
|
|
30
|
+
|
|
31
|
+
mounted = await DatabaseManager().run(
|
|
32
|
+
USDBArchiveModule(),
|
|
33
|
+
DatabaseConfig(url=database_url),
|
|
34
|
+
)
|
|
35
|
+
archive_api = mounted.api
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The package is PostgreSQL-only. Legacy SQLite models remain available solely
|
|
39
|
+
for migration compatibility.
|
|
40
|
+
|
|
41
|
+
## Packaged migration interface
|
|
42
|
+
|
|
43
|
+
`usdb-archive-migrate check|upgrade` is the only production schema writer for
|
|
44
|
+
`ultima_archive`. It reads a mode-0600 URL file, verifies the exact database,
|
|
45
|
+
rejects unknown revisions and privileged cluster roles, serializes with a
|
|
46
|
+
PostgreSQL advisory lock, and emits a JSON report.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
usdb-archive-migrate check \
|
|
50
|
+
--database-url-file /protected/archive_database_url \
|
|
51
|
+
--expected-head d8f4b2a19c60
|
|
52
|
+
|
|
53
|
+
usdb-archive-migrate upgrade \
|
|
54
|
+
--database-url-file /protected/archive_database_url \
|
|
55
|
+
--expected-head d8f4b2a19c60
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The expected head must exactly match the packaged single-head Alembic graph.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# UltimaScraperDBArchive
|
|
2
|
+
|
|
3
|
+
UltimaScraperDBArchive is the archive database module hosted by the domain-neutral
|
|
4
|
+
`ultima-scraper-db` runtime. It owns archive models and constructs `ArchiveAPI`;
|
|
5
|
+
it does not own engine or session lifecycle.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from ultima_scraper_db import DatabaseConfig, DatabaseManager
|
|
9
|
+
from ultima_scraper_db_archive import USDBArchiveModule
|
|
10
|
+
|
|
11
|
+
mounted = await DatabaseManager().run(
|
|
12
|
+
USDBArchiveModule(),
|
|
13
|
+
DatabaseConfig(url=database_url),
|
|
14
|
+
)
|
|
15
|
+
archive_api = mounted.api
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The package is PostgreSQL-only. Legacy SQLite models remain available solely
|
|
19
|
+
for migration compatibility.
|
|
20
|
+
|
|
21
|
+
## Packaged migration interface
|
|
22
|
+
|
|
23
|
+
`usdb-archive-migrate check|upgrade` is the only production schema writer for
|
|
24
|
+
`ultima_archive`. It reads a mode-0600 URL file, verifies the exact database,
|
|
25
|
+
rejects unknown revisions and privileged cluster roles, serializes with a
|
|
26
|
+
PostgreSQL advisory lock, and emits a JSON report.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
usdb-archive-migrate check \
|
|
30
|
+
--database-url-file /protected/archive_database_url \
|
|
31
|
+
--expected-head d8f4b2a19c60
|
|
32
|
+
|
|
33
|
+
usdb-archive-migrate upgrade \
|
|
34
|
+
--database-url-file /protected/archive_database_url \
|
|
35
|
+
--expected-head d8f4b2a19c60
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The expected head must exactly match the packaged single-head Alembic graph.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ultima-scraper-db-archive"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Archive database module hosted by the UltimaScraperDB runtime"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.14,<3.15"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "UltimaHoarder", email = "21285176+UltimaHoarder@users.noreply.github.com" },
|
|
10
|
+
]
|
|
11
|
+
dependencies = [
|
|
12
|
+
"alembic>=1.14,<2",
|
|
13
|
+
"ultima-scraper-db>=0.5,<1",
|
|
14
|
+
"ultima-scraper-core>=0.1,<1",
|
|
15
|
+
"ultima-scraper-api>=3.0.0b5,<4",
|
|
16
|
+
"cryptography>=50,<51",
|
|
17
|
+
"psycopg[binary]>=3.3,<4",
|
|
18
|
+
"sqlmodel>=0.0.24,<1",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/UltimaHoarder/UltimaScraperDBArchive"
|
|
23
|
+
Repository = "https://github.com/UltimaHoarder/UltimaScraperDBArchive"
|
|
24
|
+
Issues = "https://github.com/UltimaHoarder/UltimaScraperDBArchive/issues"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
usdb-archive-migrate = "ultima_scraper_db_archive.migration_cli:main"
|
|
28
|
+
|
|
29
|
+
[tool.uv.sources]
|
|
30
|
+
ultima-scraper-db = { git = "https://github.com/DATAHOARDERS/UltimaScraperDB.git", branch = "main" }
|
|
31
|
+
ultima-scraper-core = { git = "https://github.com/UltimaHoarder/UltimaScraper.git", subdirectory = "src/UltimaScraperCore", branch = "main" }
|
|
32
|
+
ultima-scraper-api = { git = "https://github.com/UltimaHoarder/UltimaScraperAPI.git", branch = "main" }
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = [
|
|
36
|
+
"pytest>=8.2,<9",
|
|
37
|
+
"pytest-asyncio>=0.23,<2",
|
|
38
|
+
"ruff>=0.12,<1",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[build-system]
|
|
42
|
+
requires = ["hatchling"]
|
|
43
|
+
build-backend = "hatchling.build"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel]
|
|
46
|
+
packages = ["ultima_scraper_db_archive"]
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
asyncio_mode = "auto"
|
|
50
|
+
testpaths = ["tests"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
exclude = [
|
|
54
|
+
"ultima_scraper_db_archive/_legacy_sqlite_models.py",
|
|
55
|
+
"ultima_scraper_db_archive/migrations",
|
|
56
|
+
"ultima_scraper_db_archive/site.py",
|
|
57
|
+
]
|
|
58
|
+
line-length = 88
|
|
59
|
+
target-version = "py314"
|
|
60
|
+
|
|
61
|
+
[tool.ruff.lint]
|
|
62
|
+
select = ["E4", "E7", "E9", "F", "I"]
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from ultima_scraper_db_archive.migration_cli import (
|
|
9
|
+
MigrationRejected,
|
|
10
|
+
_acquire_lock,
|
|
11
|
+
_read_url_file,
|
|
12
|
+
_sync_url,
|
|
13
|
+
_validate_expected_head,
|
|
14
|
+
_validate_role,
|
|
15
|
+
_validate_revisions,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _secret(tmp_path: Path, value: str) -> Path:
|
|
20
|
+
path = tmp_path / "database-url"
|
|
21
|
+
path.write_text(value, encoding="utf-8")
|
|
22
|
+
path.chmod(0o600)
|
|
23
|
+
return path
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_database_url_file_is_strict(tmp_path: Path) -> None:
|
|
27
|
+
path = _secret(
|
|
28
|
+
tmp_path,
|
|
29
|
+
"postgresql://ultimascraper:secret@postgres.private.internal/ultima_archive",
|
|
30
|
+
)
|
|
31
|
+
assert "ultima_archive" in _read_url_file(path)
|
|
32
|
+
path.chmod(0o640)
|
|
33
|
+
with pytest.raises(MigrationRejected, match="mode 0600"):
|
|
34
|
+
_read_url_file(path)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_database_url_file_rejects_symlink(tmp_path: Path) -> None:
|
|
38
|
+
target = _secret(
|
|
39
|
+
tmp_path,
|
|
40
|
+
"postgresql://ultimascraper:secret@postgres.private.internal/ultima_archive",
|
|
41
|
+
)
|
|
42
|
+
link = tmp_path / "linked-url"
|
|
43
|
+
os.symlink(target, link)
|
|
44
|
+
with pytest.raises(MigrationRejected, match="symlink"):
|
|
45
|
+
_read_url_file(link)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@pytest.mark.parametrize(
|
|
49
|
+
"url",
|
|
50
|
+
[
|
|
51
|
+
"postgresql://ultimascraper:secret@postgres/ultima_panel",
|
|
52
|
+
"postgresql://ultimascraper:secret@postgres/ultima_archive?dbname=other",
|
|
53
|
+
"sqlite:///ultima_archive",
|
|
54
|
+
],
|
|
55
|
+
)
|
|
56
|
+
def test_database_url_rejects_wrong_or_rerouted_target(
|
|
57
|
+
tmp_path: Path, url: str
|
|
58
|
+
) -> None:
|
|
59
|
+
with pytest.raises(MigrationRejected, match="exactly ultima_archive"):
|
|
60
|
+
_read_url_file(_secret(tmp_path, url))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_revision_guards_reject_unknown_and_mismatched_head() -> None:
|
|
64
|
+
with pytest.raises(MigrationRejected, match="unknown starting"):
|
|
65
|
+
_validate_revisions(frozenset({"foreign"}), frozenset({"known"}))
|
|
66
|
+
with pytest.raises(MigrationRejected, match="packaged migration graph"):
|
|
67
|
+
_validate_expected_head("wrong", frozenset({"right"}))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_async_url_is_normalized_for_guard_connection() -> None:
|
|
71
|
+
assert _sync_url("postgresql+asyncpg://u:p@db/name") == (
|
|
72
|
+
"postgresql+psycopg://u:p@db/name"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class _Result:
|
|
77
|
+
def __init__(self, value: object) -> None:
|
|
78
|
+
self.value = value
|
|
79
|
+
|
|
80
|
+
def scalar_one(self) -> object:
|
|
81
|
+
return self.value
|
|
82
|
+
|
|
83
|
+
def one(self) -> object:
|
|
84
|
+
return self.value
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class _Connection:
|
|
88
|
+
def __init__(self, values: list[object]) -> None:
|
|
89
|
+
self.values = iter(values)
|
|
90
|
+
|
|
91
|
+
def execute(self, *_args: object, **_kwargs: object) -> _Result:
|
|
92
|
+
return _Result(next(self.values))
|
|
93
|
+
|
|
94
|
+
def commit(self) -> None:
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_concurrent_migration_lock_is_rejected() -> None:
|
|
99
|
+
with pytest.raises(MigrationRejected, match="another migration"):
|
|
100
|
+
_acquire_lock(_Connection([False])) # type: ignore[arg-type]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_privileged_cluster_role_is_rejected() -> None:
|
|
104
|
+
role = ("ultimascraper", "ultima_archive", True, False, False, False, False)
|
|
105
|
+
with pytest.raises(MigrationRejected, match="superuser"):
|
|
106
|
+
_validate_role(_Connection([role])) # type: ignore[arg-type]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_transient_concurrent_indexes_are_skipped() -> None:
|
|
110
|
+
from ultima_scraper_db_archive.history_alembic import (
|
|
111
|
+
include_name,
|
|
112
|
+
is_transient_concurrent_index,
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
assert is_transient_concurrent_index("execution_work_payloads_pkey_ccnew") is True
|
|
116
|
+
assert is_transient_concurrent_index("execution_work_payloads_pkey_ccold") is True
|
|
117
|
+
assert is_transient_concurrent_index("execution_work_payloads_pkey") is False
|
|
118
|
+
assert is_transient_concurrent_index(None) is False
|
|
119
|
+
|
|
120
|
+
assert include_name("execution_work_payloads_pkey_ccnew", "index", {}) is False
|
|
121
|
+
assert include_name("execution_work_payloads_pkey_ccold", "index", {}) is False
|
|
122
|
+
assert include_name("execution_work_payloads_pkey", "index", {}) is True
|
|
123
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import inspect
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from alembic.script import ScriptDirectory
|
|
9
|
+
from ultima_scraper_db import DatabaseDefinition
|
|
10
|
+
|
|
11
|
+
from ultima_scraper_db_archive import MIGRATION_BUNDLE, ArchiveAPI, USDBArchiveModule
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_archive_exposes_an_opaque_usdb_module() -> None:
|
|
15
|
+
module = USDBArchiveModule()
|
|
16
|
+
|
|
17
|
+
assert isinstance(module.definition, DatabaseDefinition)
|
|
18
|
+
assert module.definition.key == "usdb-archive"
|
|
19
|
+
assert module.definition.migrations is MIGRATION_BUNDLE
|
|
20
|
+
assert MIGRATION_BUNDLE.config_path.is_file()
|
|
21
|
+
assert "management" in module.definition.schemas
|
|
22
|
+
assert "pg_trgm" in module.definition.required_extensions
|
|
23
|
+
assert module.definition.optional_extensions == ("vector",)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_archive_constructs_its_own_domain_api() -> None:
|
|
27
|
+
module = USDBArchiveModule()
|
|
28
|
+
handle: Any = object()
|
|
29
|
+
|
|
30
|
+
api = module.create_api(handle)
|
|
31
|
+
|
|
32
|
+
assert isinstance(api, ArchiveAPI)
|
|
33
|
+
assert api.database is handle
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_archive_does_not_import_the_usr_backend() -> None:
|
|
37
|
+
subprocess.run(
|
|
38
|
+
[
|
|
39
|
+
sys.executable,
|
|
40
|
+
"-c",
|
|
41
|
+
(
|
|
42
|
+
"import sys; import ultima_scraper_db_archive; "
|
|
43
|
+
"assert 'ultima_scraper_backend' not in sys.modules"
|
|
44
|
+
),
|
|
45
|
+
],
|
|
46
|
+
check=True,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_archive_head_owns_search_loadout_schema_and_sequence_repair() -> None:
|
|
51
|
+
config = MIGRATION_BUNDLE.create_config(
|
|
52
|
+
"postgresql+psycopg://unused:unused@localhost/ultima_archive"
|
|
53
|
+
)
|
|
54
|
+
graph = ScriptDirectory.from_config(config)
|
|
55
|
+
|
|
56
|
+
assert graph.get_heads() == ["7a2d9c4e1f80"]
|
|
57
|
+
revision = graph.get_revision("7a2d9c4e1f80")
|
|
58
|
+
assert revision is not None
|
|
59
|
+
assert revision.down_revision == "f6a1c8e29b47"
|
|
60
|
+
source = inspect.getsource(revision.module.upgrade)
|
|
61
|
+
assert "management.search_loadouts" in source
|
|
62
|
+
assert "setval" in source
|
|
63
|
+
assert "content_media_asso" in revision.module.RUNTIME_SEQUENCE_TABLES
|
|
64
|
+
assert "filepaths" in revision.module.RUNTIME_SEQUENCE_TABLES
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Primary database model exports for UltimaScraper.
|
|
2
|
+
|
|
3
|
+
Package-level imports should resolve to the active PostgreSQL-backed models.
|
|
4
|
+
The legacy sqlite ``site.py`` module is retained only for compatibility helpers
|
|
5
|
+
such as ``DEFAULT_DB_PATH``.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from .databases.ultima_archive.schemas.templates.postgres_site import (
|
|
13
|
+
BackendInventoryModel,
|
|
14
|
+
BoughtContentModel,
|
|
15
|
+
CentralJobModel,
|
|
16
|
+
CentralTaskModel,
|
|
17
|
+
ContentMediaAssoModel,
|
|
18
|
+
ContentMentionModel,
|
|
19
|
+
DRMManifestModel,
|
|
20
|
+
FavoriteUserModel,
|
|
21
|
+
FilePathModel,
|
|
22
|
+
HistoUserInfoModel,
|
|
23
|
+
InvalidUserModel,
|
|
24
|
+
LinkedPostModel,
|
|
25
|
+
LinkedUserModel,
|
|
26
|
+
MassMessageModel,
|
|
27
|
+
MediaModel,
|
|
28
|
+
MessageModel,
|
|
29
|
+
PostModel,
|
|
30
|
+
ProxyGeolocationModel,
|
|
31
|
+
RemoteURLModel,
|
|
32
|
+
SearchLoadoutModel,
|
|
33
|
+
SettingsModel,
|
|
34
|
+
SiteTemplate,
|
|
35
|
+
SocialModel,
|
|
36
|
+
StatisticsModel,
|
|
37
|
+
StoryModel,
|
|
38
|
+
SubscriptionModel,
|
|
39
|
+
UserAliasModel,
|
|
40
|
+
UserAuthModel,
|
|
41
|
+
UserInfoModel,
|
|
42
|
+
UserModel,
|
|
43
|
+
UserProfileMediaModel,
|
|
44
|
+
WebsiteModel,
|
|
45
|
+
content_types,
|
|
46
|
+
utcnow,
|
|
47
|
+
)
|
|
48
|
+
from .module import MIGRATION_BUNDLE, ArchiveAPI, USDBArchiveModule
|
|
49
|
+
|
|
50
|
+
# Keep the historical SQLite filename so migration discovery still finds
|
|
51
|
+
# existing archives after the distribution/package rename.
|
|
52
|
+
DEFAULT_DB_PATH = Path.home() / ".ultima_scraper" / "ultima_scraper_mini.db"
|
|
53
|
+
|
|
54
|
+
# Backwards-compatible alias for older imports that expected JobModel at the
|
|
55
|
+
# package root. Central jobs now live in PostgreSQL management tables.
|
|
56
|
+
JobModel = CentralJobModel
|
|
57
|
+
|
|
58
|
+
__all__ = [
|
|
59
|
+
"BackendInventoryModel",
|
|
60
|
+
"BoughtContentModel",
|
|
61
|
+
"CentralJobModel",
|
|
62
|
+
"CentralTaskModel",
|
|
63
|
+
"ContentMediaAssoModel",
|
|
64
|
+
"ContentMentionModel",
|
|
65
|
+
"content_types",
|
|
66
|
+
"DEFAULT_DB_PATH",
|
|
67
|
+
"DRMManifestModel",
|
|
68
|
+
"FavoriteUserModel",
|
|
69
|
+
"FilePathModel",
|
|
70
|
+
"HistoUserInfoModel",
|
|
71
|
+
"InvalidUserModel",
|
|
72
|
+
"JobModel",
|
|
73
|
+
"LinkedPostModel",
|
|
74
|
+
"LinkedUserModel",
|
|
75
|
+
"MassMessageModel",
|
|
76
|
+
"MediaModel",
|
|
77
|
+
"MessageModel",
|
|
78
|
+
"PostModel",
|
|
79
|
+
"ProxyGeolocationModel",
|
|
80
|
+
"RemoteURLModel",
|
|
81
|
+
"SearchLoadoutModel",
|
|
82
|
+
"SettingsModel",
|
|
83
|
+
"SiteTemplate",
|
|
84
|
+
"SocialModel",
|
|
85
|
+
"StoryModel",
|
|
86
|
+
"StatisticsModel",
|
|
87
|
+
"SubscriptionModel",
|
|
88
|
+
"UserAliasModel",
|
|
89
|
+
"UserAuthModel",
|
|
90
|
+
"UserInfoModel",
|
|
91
|
+
"UserModel",
|
|
92
|
+
"UserProfileMediaModel",
|
|
93
|
+
"utcnow",
|
|
94
|
+
"WebsiteModel",
|
|
95
|
+
"ArchiveAPI",
|
|
96
|
+
"MIGRATION_BUNDLE",
|
|
97
|
+
"USDBArchiveModule",
|
|
98
|
+
]
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""Legacy SQLite models for bootstrap fallback.
|
|
2
|
+
|
|
3
|
+
These mirror the management tables in a flat SQLite schema so the app
|
|
4
|
+
can read/write settings before the postgres connection is established.
|
|
5
|
+
|
|
6
|
+
.. deprecated::
|
|
7
|
+
Once the first-time setup completes and postgres is configured,
|
|
8
|
+
all data lives in ``management.*`` tables inside ``ultima_archive``.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from datetime import datetime, timezone
|
|
14
|
+
|
|
15
|
+
from sqlalchemy import Integer, MetaData, String
|
|
16
|
+
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
17
|
+
|
|
18
|
+
legacy_metadata = MetaData()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _utcnow() -> datetime:
|
|
22
|
+
return datetime.now(timezone.utc)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class _LegacyBase(DeclarativeBase):
|
|
26
|
+
metadata = legacy_metadata
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SettingsModel(_LegacyBase):
|
|
30
|
+
"""Settings table in SQLite (bootstrap only)."""
|
|
31
|
+
|
|
32
|
+
__tablename__ = "settings"
|
|
33
|
+
|
|
34
|
+
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
35
|
+
backend: Mapped[str] = mapped_column(String(64), index=True)
|
|
36
|
+
key: Mapped[str] = mapped_column(String(128), index=True)
|
|
37
|
+
value: Mapped[str] = mapped_column(String)
|
|
38
|
+
is_secret: Mapped[bool] = mapped_column(default=False)
|
|
39
|
+
description: Mapped[str | None] = mapped_column(String, default=None)
|
|
40
|
+
version: Mapped[int] = mapped_column(Integer, default=1)
|
|
41
|
+
created_at: Mapped[datetime] = mapped_column(default=_utcnow)
|
|
42
|
+
updated_at: Mapped[datetime] = mapped_column(default=_utcnow, onupdate=_utcnow)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CentralJobModel(_LegacyBase):
|
|
46
|
+
"""Jobs table in SQLite (bootstrap only)."""
|
|
47
|
+
|
|
48
|
+
__tablename__ = "jobs"
|
|
49
|
+
|
|
50
|
+
job_id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
51
|
+
job_type: Mapped[str] = mapped_column(String(64), index=True)
|
|
52
|
+
site: Mapped[str] = mapped_column(String(64), index=True)
|
|
53
|
+
status: Mapped[str] = mapped_column(String(32), index=True, default="pending")
|
|
54
|
+
priority: Mapped[int] = mapped_column(Integer, default=0)
|
|
55
|
+
worker_id: Mapped[str | None] = mapped_column(String(64), index=True, default=None)
|
|
56
|
+
retries: Mapped[int] = mapped_column(Integer, default=0)
|
|
57
|
+
max_retries: Mapped[int] = mapped_column(Integer, default=3)
|
|
58
|
+
args_json: Mapped[str] = mapped_column(default="{}")
|
|
59
|
+
auth_json: Mapped[str | None] = mapped_column(default=None)
|
|
60
|
+
user_auth_id: Mapped[int | None] = mapped_column(Integer, default=None)
|
|
61
|
+
created_at: Mapped[datetime] = mapped_column(default=_utcnow)
|
|
62
|
+
started_at: Mapped[datetime | None] = mapped_column(default=None)
|
|
63
|
+
completed_at: Mapped[datetime | None] = mapped_column(default=None)
|
|
64
|
+
last_event_at: Mapped[datetime | None] = mapped_column(default=None)
|
|
65
|
+
result_success: Mapped[bool | None] = mapped_column(default=None)
|
|
66
|
+
result_message: Mapped[str | None] = mapped_column(default=None)
|
|
67
|
+
result_error: Mapped[str | None] = mapped_column(default=None)
|
|
68
|
+
result_data_json: Mapped[str | None] = mapped_column(default=None)
|
|
69
|
+
result_completed_at: Mapped[datetime | None] = mapped_column(default=None)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class CentralTaskModel(_LegacyBase):
|
|
73
|
+
"""Job tasks table in SQLite (bootstrap only)."""
|
|
74
|
+
|
|
75
|
+
__tablename__ = "job_tasks"
|
|
76
|
+
|
|
77
|
+
task_id: Mapped[str] = mapped_column(String(64), primary_key=True)
|
|
78
|
+
job_id: Mapped[str] = mapped_column(String(64), index=True)
|
|
79
|
+
task_type: Mapped[str] = mapped_column(String(64), index=True)
|
|
80
|
+
status: Mapped[str] = mapped_column(String(32), index=True, default="pending")
|
|
81
|
+
site: Mapped[str | None] = mapped_column(String(64), index=True, default=None)
|
|
82
|
+
username: Mapped[str | None] = mapped_column(String(128), default=None)
|
|
83
|
+
content_type: Mapped[str | None] = mapped_column(String(64), default=None)
|
|
84
|
+
auth_id: Mapped[int | None] = mapped_column(Integer, default=None)
|
|
85
|
+
items_processed: Mapped[int] = mapped_column(Integer, default=0)
|
|
86
|
+
items_total: Mapped[int | None] = mapped_column(Integer, default=None)
|
|
87
|
+
created_at: Mapped[datetime] = mapped_column(default=_utcnow)
|
|
88
|
+
started_at: Mapped[datetime | None] = mapped_column(default=None)
|
|
89
|
+
completed_at: Mapped[datetime | None] = mapped_column(default=None)
|
|
90
|
+
last_event_at: Mapped[datetime | None] = mapped_column(default=None)
|
|
91
|
+
error: Mapped[str | None] = mapped_column(default=None)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class ProxyGeolocationModel(_LegacyBase):
|
|
95
|
+
"""Proxy geolocation cache in SQLite (bootstrap only)."""
|
|
96
|
+
|
|
97
|
+
__tablename__ = "proxy_geolocation"
|
|
98
|
+
|
|
99
|
+
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
100
|
+
ip: Mapped[str] = mapped_column(String(45), unique=True, index=True)
|
|
101
|
+
proxy_url: Mapped[str | None] = mapped_column(String(512), index=True, default=None)
|
|
102
|
+
ip_type: Mapped[str | None] = mapped_column(String(10), default=None)
|
|
103
|
+
continent: Mapped[str | None] = mapped_column(String(50), default=None)
|
|
104
|
+
country: Mapped[str | None] = mapped_column(String(100), default=None)
|
|
105
|
+
country_code: Mapped[str | None] = mapped_column(String(5), default=None)
|
|
106
|
+
region: Mapped[str | None] = mapped_column(String(100), default=None)
|
|
107
|
+
city: Mapped[str | None] = mapped_column(String(100), default=None)
|
|
108
|
+
latitude: Mapped[float | None] = mapped_column(default=None)
|
|
109
|
+
longitude: Mapped[float | None] = mapped_column(default=None)
|
|
110
|
+
postal: Mapped[str | None] = mapped_column(String(20), default=None)
|
|
111
|
+
flag_emoji: Mapped[str | None] = mapped_column(String(10), default=None)
|
|
112
|
+
flag_img: Mapped[str | None] = mapped_column(String(255), default=None)
|
|
113
|
+
asn: Mapped[int | None] = mapped_column(default=None)
|
|
114
|
+
org: Mapped[str | None] = mapped_column(String(255), default=None)
|
|
115
|
+
isp: Mapped[str | None] = mapped_column(String(255), default=None)
|
|
116
|
+
isp_domain: Mapped[str | None] = mapped_column(String(255), default=None)
|
|
117
|
+
timezone_id: Mapped[str | None] = mapped_column(String(50), default=None)
|
|
118
|
+
timezone_abbr: Mapped[str | None] = mapped_column(String(10), default=None)
|
|
119
|
+
timezone_utc: Mapped[str | None] = mapped_column(String(10), default=None)
|
|
120
|
+
created_at: Mapped[datetime] = mapped_column(default=_utcnow)
|
|
121
|
+
updated_at: Mapped[datetime] = mapped_column(default=_utcnow, onupdate=_utcnow)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Helpers that keep Alembic reflection deterministic through PgBouncer."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from sqlalchemy.engine import Connection
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def normalize_postgresql_reflection(connection: Connection) -> None:
|
|
9
|
+
"""Normalize PostgreSQL reflection inside Alembic's active transaction."""
|
|
10
|
+
|
|
11
|
+
if connection.dialect.name != "postgresql":
|
|
12
|
+
return
|
|
13
|
+
if not connection.in_transaction():
|
|
14
|
+
raise RuntimeError(
|
|
15
|
+
"PostgreSQL reflection must be normalized inside Alembic's transaction"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
connection.exec_driver_sql("SET LOCAL search_path TO public")
|
|
19
|
+
connection.dialect.default_schema_name = "public"
|