Skip to content

Commit 0eec717

Browse files
committed
Updated view generation script to handle more generic migration contracts, sample migration contract for workshop and small bug on the backend while retrieving product using the migrated GSI
1 parent 8cf87cb commit 0eec717

File tree

4 files changed

+506
-274
lines changed

4 files changed

+506
-274
lines changed

workshops/modernizr/backend/src/database/implementations/dynamodb/DynamoDBProductRepository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export class DynamoDBProductRepository extends BaseDynamoDBRepository implements
298298

299299
private async transformFromDynamoDB(item: any): Promise<ProductWithDetails> {
300300
const product: ProductWithDetails = {
301-
id: parseInt(item.id),
301+
id: parseInt(item.PK),
302302
seller_id: parseInt(item.seller_id),
303303
category_id: parseInt(item.category_id),
304304
name: item.product_name || item.name,

workshops/modernizr/core-outputs/stage-02/migrationContract.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@
473473
"condition": "parent_id IS NULL",
474474
"target_table": "categories",
475475
"join_condition": "categories.id = categories.parent_id",
476-
"select_column": "categories.name",
477-
"else_value": "ROOT"
476+
"select_column": "'ROOT'",
477+
"else_value": "parent.name"
478478
}
479479
},
480480
{
@@ -521,7 +521,7 @@
521521
"join": {
522522
"type": "self-join",
523523
"join_alias": "cat_path",
524-
"join_condition": "cat_path.parent_id = categories.id",
524+
"join_condition": "cat_path.id = categories.parent_id",
525525
"select_column": "cat_path.name",
526526
"null_value": ""
527527
},
@@ -583,8 +583,8 @@
583583
"condition": "parent_id IS NULL",
584584
"target_table": "categories",
585585
"join_condition": "categories.id = categories.parent_id",
586-
"select_column": "categories.id",
587-
"else_value": "ROOT"
586+
"select_column": "'ROOT'",
587+
"else_value": "parent.id"
588588
}
589589
},
590590
{

workshops/modernizr/tools/contract_driven_migration_glue_mcp.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ def execute_mysql_views_via_mcp(view_sql, mysql_config, config):
5151

5252
mysql_defaults = config.get('mysql', {})
5353

54-
# Parse SQL statements
54+
# Parse SQL statements - improved logic
5555
statements = []
5656
current_statement = ""
57-
in_view = False
5857

5958
for line in view_sql.split('\n'):
6059
line = line.strip()
@@ -65,16 +64,15 @@ def execute_mysql_views_via_mcp(view_sql, mysql_config, config):
6564
if current_statement:
6665
statements.append(current_statement.strip())
6766
current_statement = line
68-
in_view = True
69-
elif in_view:
67+
else:
7068
current_statement += '\n' + line
71-
if line.endswith(';'):
72-
statements.append(current_statement.strip())
73-
current_statement = ""
74-
in_view = False
69+
70+
if line.endswith(';'):
71+
statements.append(current_statement.strip())
72+
current_statement = ""
7573

76-
if current_statement and in_view:
77-
statements.append(current_statement.strip() + ';')
74+
if current_statement:
75+
statements.append(current_statement.strip())
7876

7977
print(f" 📋 Found {len(statements)} view statements to execute")
8078

0 commit comments

Comments
 (0)