@@ -43,6 +43,10 @@ const (
4343	DOLTGRES_DATA_DIR  =  "DOLTGRES_DATA_DIR" 
4444	// DOLTGRES_DATA_DIR_DEFAULT is the portion to append to the user's home directory if DOLTGRES_DATA_DIR has not been specified 
4545	DOLTGRES_DATA_DIR_DEFAULT  =  "doltgres/databases" 
46+ 
47+ 	DefUserName   =  "postres" 
48+ 	DefUserEmail  =  "[email protected] "  49+ 	DoltgresDir   =  "doltgres" 
4650)
4751
4852var  sqlServerDocs  =  cli.CommandDocumentationContent {
@@ -134,8 +138,8 @@ func RunInMemory(args []string) (*svcs.Controller, error) {
134138	globalConfig , _  :=  dEnv .Config .GetConfig (env .GlobalConfig )
135139	if  globalConfig .GetStringOrDefault (config .UserNameKey , "" ) ==  ""  {
136140		globalConfig .SetStrings (map [string ]string {
137- 			config .UserNameKey :  "postgres" ,
138- 			config .
UserEmailKey : 
"[email protected] " ,
 141+ 			config .UserNameKey :  DefUserName ,
142+ 			config .UserEmailKey : DefUserEmail ,
139143		})
140144	}
141145
@@ -188,26 +192,29 @@ func runServer(ctx context.Context, args []string, dEnv *env.DoltEnv) (*svcs.Con
188192
189193	// We need a username and password for many SQL commands, so set defaults if they don't exist 
190194	dEnv .Config .SetFailsafes (map [string ]string {
191- 		config .UserNameKey :  "postgres" ,
192- 		config .
UserEmailKey : 
"[email protected] " ,
 195+ 		config .UserNameKey :  DefUserName ,
196+ 		config .UserEmailKey : DefUserEmail ,
193197	})
194198
195199	// Automatically initialize a doltgres database if necessary 
196200	if  ! dEnv .HasDoltDir () {
197201		// Need to make sure that there isn't a doltgres item in the path. 
198- 		if  exists , isDirectory  :=  dEnv .FS .Exists ("doltgres" ); ! exists  {
199- 			err  :=  dEnv .FS .MkDirs ("doltgres" )
202+ 		if  exists , isDirectory  :=  dEnv .FS .Exists (DoltgresDir ); ! exists  {
203+ 			err  :=  dEnv .FS .MkDirs (DoltgresDir )
200204			if  err  !=  nil  {
201205				return  nil , err 
202206			}
203- 			subdirectoryFS , err  :=  dEnv .FS .WithWorkingDir ("doltgres" )
207+ 			subdirectoryFS , err  :=  dEnv .FS .WithWorkingDir (DoltgresDir )
204208			if  err  !=  nil  {
205209				return  nil , err 
206210			}
207211
208212			// We'll use a temporary environment to instantiate the subdirectory 
209213			tempDEnv  :=  env .Load (ctx , env .GetCurrentUserHomeDir , subdirectoryFS , dEnv .UrlStr (), Version )
210- 			res  :=  commands.InitCmd {}.Exec (ctx , "init" , []string {}, tempDEnv , configCliContext {tempDEnv })
214+ 			// username and user email is needed for creating a database. 
215+ 			name  :=  dEnv .Config .GetStringOrDefault (config .UserNameKey , DefUserName )
216+ 			email  :=  dEnv .Config .GetStringOrDefault (config .UserEmailKey , DefUserEmail )
217+ 			res  :=  commands.InitCmd {}.Exec (ctx , "init" , []string {"--name" , name , "--email" , email }, tempDEnv , configCliContext {tempDEnv })
211218			if  res  !=  0  {
212219				return  nil , fmt .Errorf ("failed to initialize doltgres database" )
213220			}
0 commit comments