SHAFI commited on
Commit
6964e58
·
1 Parent(s): dbfb079

fix(db): map new schema fields to legacy cloud collection schema

Browse files

- Specific fix for Cloud Collection (legacy schema):
- Map image_url -> image
- Map published_at -> publishedAt
- Resolves 'Unknown attribute' errors for cloud-* categories

Files changed (1) hide show
  1. app/services/appwrite_db.py +10 -0
app/services/appwrite_db.py CHANGED
@@ -398,6 +398,16 @@ class AppwriteDatabase:
398
  if target_collection_id == settings.APPWRITE_CLOUD_COLLECTION_ID:
399
  document_data['provider'] = document_data['source']
400
  document_data['is_official'] = False # Default to False
 
 
 
 
 
 
 
 
 
 
401
 
402
  # Try to create document
403
  self.tablesDB.create_row(
 
398
  if target_collection_id == settings.APPWRITE_CLOUD_COLLECTION_ID:
399
  document_data['provider'] = document_data['source']
400
  document_data['is_official'] = False # Default to False
401
+
402
+ # FIX: Cloud collection uses legacy 'image' attribute, not 'image_url'
403
+ if 'image_url' in document_data:
404
+ document_data['image'] = document_data.pop('image_url')
405
+
406
+ # FIX: Cloud collection uses legacy 'publishedAt' attribute, not 'published_at'
407
+ # Based on logs, other collections accept 'published_at' (snake_case)
408
+ # But Cloud might strictly require 'publishedAt' (camelCase)
409
+ if 'published_at' in document_data:
410
+ document_data['publishedAt'] = document_data.pop('published_at')
411
 
412
  # Try to create document
413
  self.tablesDB.create_row(