@@ -3232,6 +3232,62 @@ def test_virtual_environment_mode_dev_only_model_change_standalone_audit(
32323232 context .apply (plan )
32333233
32343234
3235+ @time_machine .travel ("2023-01-08 15:00:00 UTC" )
3236+ def test_virtual_environment_mode_dev_only_seed_model_change_schema (
3237+ init_and_plan_context : t .Callable ,
3238+ ):
3239+ context , plan = init_and_plan_context (
3240+ "examples/sushi" , config = "test_config_virtual_environment_mode_dev_only"
3241+ )
3242+ context .apply (plan )
3243+
3244+ new_csv = []
3245+ with open (context .path / "seeds" / "waiter_names.csv" , "r" ) as fd :
3246+ is_header = True
3247+ for idx , line in enumerate (fd ):
3248+ line = line .strip ()
3249+ if not line :
3250+ continue
3251+ if is_header :
3252+ new_csv .append (line + ",new_column" )
3253+ is_header = False
3254+ else :
3255+ new_csv .append (line + f",v{ idx } " )
3256+
3257+ with open (context .path / "seeds" / "waiter_names.csv" , "w" ) as fd :
3258+ fd .write ("\n " .join (new_csv ))
3259+
3260+ context .load ()
3261+
3262+ downstream_model = context .get_model ("sushi.waiter_as_customer_by_day" )
3263+ downstream_model_kind = downstream_model .kind .dict ()
3264+ downstream_model_kwargs = {
3265+ ** downstream_model .dict (),
3266+ "kind" : {
3267+ ** downstream_model_kind ,
3268+ "on_destructive_change" : "allow" ,
3269+ },
3270+ "audits" : [],
3271+ # Use the new column
3272+ "query" : "SELECT '2023-01-07' AS event_date, new_column AS new_column FROM sushi.waiter_names" ,
3273+ }
3274+ context .upsert_model (SqlModel .parse_obj (downstream_model_kwargs ))
3275+
3276+ context .plan ("dev" , auto_apply = True , no_prompts = True , skip_tests = True , enable_preview = True )
3277+
3278+ assert (
3279+ context .engine_adapter .fetchone (
3280+ "SELECT COUNT(*) FROM sushi__dev.waiter_as_customer_by_day"
3281+ )[0 ]
3282+ == len (new_csv ) - 1
3283+ )
3284+
3285+ # Deploy to prod
3286+ context .clear_caches ()
3287+ context .plan ("prod" , auto_apply = True , no_prompts = True , skip_tests = True )
3288+ assert "new_column" in context .engine_adapter .columns ("sushi.waiter_as_customer_by_day" )
3289+
3290+
32353291@time_machine .travel ("2023-01-08 15:00:00 UTC" )
32363292def test_restatement_plan_ignores_changes (init_and_plan_context : t .Callable ):
32373293 context , plan = init_and_plan_context ("examples/sushi" )
0 commit comments