File tree Expand file tree Collapse file tree 5 files changed +12
-2
lines changed Expand file tree Collapse file tree 5 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ export default async function sync(options: {
9999 await driver . createUser ( {
100100 username : account . username ,
101101 password : password ,
102+ root : account . root ,
102103 } ) ;
103104 log ( "success" , alias , "User created" ) ;
104105 } else {
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ export type GlobalOptions = RootAccount & {
1414export type CreateUserOptions = {
1515 username : string ;
1616 password : Password ;
17+ root ?: boolean ;
1718} ;
1819
1920export type CreateDatabaseOptions = {
Original file line number Diff line number Diff line change @@ -13,9 +13,14 @@ import {
1313export default class MysqlDriver extends DriverAbstract {
1414 override async createUser ( options : CreateUserOptions ) {
1515 const password = await parsePassword ( options . password ) ;
16+ const { username } = options ;
1617 await this . query (
17- `CREATE USER '${ options . username } '@'%' IDENTIFIED BY '${ password } ';`
18+ `CREATE USER '${ username } '@'%' IDENTIFIED BY '${ password } ';`
1819 ) ;
20+ if ( options . root )
21+ await this . query (
22+ `GRANT ALL PRIVILEGES ON *.* TO '${ username } '@'%' WITH GRANT OPTION;`
23+ ) ;
1924 }
2025
2126 override async createDatabase ( options : CreateDatabaseOptions ) {
Original file line number Diff line number Diff line change @@ -13,9 +13,11 @@ import {
1313export default class PostgresDriver extends DriverAbstract {
1414 override async createUser ( options : CreateUserOptions ) {
1515 const password = await parsePassword ( options . password ) ;
16+ const { username } = options ;
1617 await this . query (
17- `CREATE USER "${ options . username } " WITH ENCRYPTED PASSWORD '${ password } ';`
18+ `CREATE USER "${ username } " WITH ENCRYPTED PASSWORD '${ password } ';`
1819 ) ;
20+ if ( options . root ) await this . query ( `ALTER ROLE "${ username } " SUPERUSER;` ) ;
1921 }
2022
2123 override async createDatabase ( options : CreateDatabaseOptions ) {
Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ export type RootAccount = {
8484export type Account = {
8585 username : string ;
8686 password : Password ;
87+ root ?: boolean ;
8788 createDatabase ?: boolean ;
8889 /**
8990 * @default createDatabase
You can’t perform that action at this time.
0 commit comments