@@ -348,6 +348,22 @@ func (e *Executor) alterSettingsConstant(ps *model.ProjectSettings, stmt *ast.Al
348348 return fmt .Errorf ("configuration not found: %s" , targetConfig )
349349 }
350350
351+ if stmt .DropConstant {
352+ // Remove the constant override
353+ for i , cv := range cfg .ConstantValues {
354+ if cv .ConstantId == stmt .ConstantId {
355+ cfg .ConstantValues = append (cfg .ConstantValues [:i ], cfg .ConstantValues [i + 1 :]... )
356+ if err := e .writer .UpdateProjectSettings (ps ); err != nil {
357+ return fmt .Errorf ("failed to update project settings: %w" , err )
358+ }
359+ fmt .Fprintf (e .output , "Dropped constant '%s' from configuration '%s'\n " ,
360+ stmt .ConstantId , targetConfig )
361+ return nil
362+ }
363+ }
364+ return fmt .Errorf ("constant '%s' not found in configuration '%s'" , stmt .ConstantId , targetConfig )
365+ }
366+
351367 // Find or create the constant value
352368 found := false
353369 for _ , cv := range cfg .ConstantValues {
@@ -375,6 +391,107 @@ func (e *Executor) alterSettingsConstant(ps *model.ProjectSettings, stmt *ast.Al
375391 return nil
376392}
377393
394+ // createConfiguration handles CREATE CONFIGURATION 'name' [properties...].
395+ func (e * Executor ) createConfiguration (stmt * ast.CreateConfigurationStmt ) error {
396+ if e .writer == nil {
397+ return fmt .Errorf ("not connected in write mode" )
398+ }
399+
400+ ps , err := e .reader .GetProjectSettings ()
401+ if err != nil {
402+ return fmt .Errorf ("failed to read project settings: %w" , err )
403+ }
404+
405+ if ps .Configuration == nil {
406+ return fmt .Errorf ("configuration settings not found in project" )
407+ }
408+
409+ // Check if configuration already exists
410+ for _ , cfg := range ps .Configuration .Configurations {
411+ if strings .EqualFold (cfg .Name , stmt .Name ) {
412+ return fmt .Errorf ("configuration already exists: %s" , stmt .Name )
413+ }
414+ }
415+
416+ newCfg := & model.ServerConfiguration {
417+ Name : stmt .Name ,
418+ DatabaseType : "HSQLDB" ,
419+ HttpPortNumber : 8080 ,
420+ ConstantValues : []* model.ConstantValue {},
421+ }
422+ newCfg .TypeName = "Settings$ServerConfiguration"
423+
424+ // Apply optional properties
425+ for key , val := range stmt .Properties {
426+ valStr := settingsValueToString (val )
427+ switch key {
428+ case "DatabaseType" :
429+ newCfg .DatabaseType = valStr
430+ case "DatabaseUrl" :
431+ newCfg .DatabaseUrl = valStr
432+ case "DatabaseName" :
433+ newCfg .DatabaseName = valStr
434+ case "DatabaseUserName" :
435+ newCfg .DatabaseUserName = valStr
436+ case "DatabasePassword" :
437+ newCfg .DatabasePassword = valStr
438+ case "HttpPortNumber" :
439+ if v , err := strconv .Atoi (valStr ); err == nil {
440+ newCfg .HttpPortNumber = v
441+ }
442+ case "ServerPortNumber" :
443+ if v , err := strconv .Atoi (valStr ); err == nil {
444+ newCfg .ServerPortNumber = v
445+ }
446+ case "ApplicationRootUrl" :
447+ newCfg .ApplicationRootUrl = valStr
448+ default :
449+ return fmt .Errorf ("unknown configuration property: %s" , key )
450+ }
451+ }
452+
453+ ps .Configuration .Configurations = append (ps .Configuration .Configurations , newCfg )
454+
455+ if err := e .writer .UpdateProjectSettings (ps ); err != nil {
456+ return fmt .Errorf ("failed to update project settings: %w" , err )
457+ }
458+
459+ fmt .Fprintf (e .output , "Created configuration: %s\n " , stmt .Name )
460+ return nil
461+ }
462+
463+ // dropConfiguration handles DROP CONFIGURATION 'name'.
464+ func (e * Executor ) dropConfiguration (stmt * ast.DropConfigurationStmt ) error {
465+ if e .writer == nil {
466+ return fmt .Errorf ("not connected in write mode" )
467+ }
468+
469+ ps , err := e .reader .GetProjectSettings ()
470+ if err != nil {
471+ return fmt .Errorf ("failed to read project settings: %w" , err )
472+ }
473+
474+ if ps .Configuration == nil {
475+ return fmt .Errorf ("configuration settings not found in project" )
476+ }
477+
478+ for i , cfg := range ps .Configuration .Configurations {
479+ if strings .EqualFold (cfg .Name , stmt .Name ) {
480+ ps .Configuration .Configurations = append (
481+ ps .Configuration .Configurations [:i ],
482+ ps .Configuration .Configurations [i + 1 :]... ,
483+ )
484+ if err := e .writer .UpdateProjectSettings (ps ); err != nil {
485+ return fmt .Errorf ("failed to update project settings: %w" , err )
486+ }
487+ fmt .Fprintf (e .output , "Dropped configuration: %s\n " , stmt .Name )
488+ return nil
489+ }
490+ }
491+
492+ return fmt .Errorf ("configuration not found: %s" , stmt .Name )
493+ }
494+
378495// settingsValueToString converts an AST settings value to string.
379496func settingsValueToString (val any ) string {
380497 switch v := val .(type ) {
0 commit comments