-
-
Notifications
You must be signed in to change notification settings - Fork 2
client.alterDatabase()
Oxford Harrison edited this page Nov 9, 2024
·
12 revisions
Programmatically perform an ALTER DATABASE
operation.
client.alterDatabase(
alterSpec: string | { name: string, tables?: string[] },
callback: (databaseSchema: DatabaseSchemaAPI) => void,
options?: QueryOptions
): Promise<Savepoint | boolean>;
Param | Type | Description |
---|---|---|
alterSpec |
string or object
|
A database name, or an object specifying the name and, optionally, a list of tables to be included in the retrieved database schema instance. |
callback |
function |
A callback function that recieves the requested schema. This can be async. |
options |
QueryOptions |
Standard QueryOptions . |
-
Savepoint | boolean
: a Savepoint instance (See ➞Savepoint
) or the booleantrue
when savepoint creation has been disabled viaoptions.noCreateSavepoint
; (Compare ➞ Query Return Value)
Specify database by name:
const savepoint = await client.alterDatabase(
'database_1',
(databaseSchema) => {
databaseSchema.name('database_1_new');
},
{ desc: 'Renaming for testing purposes' }
);
or by an object, with an optional list of tables to be altered along with it:
const savepoint = await client.alterDatabase(
{ name: 'database_1', tables: ['table_1'] },
(databaseSchema) => {
databaseSchema.name('database_1_new');
databaseSchema.table('table_1').column('column_1').name('column_1_new');
databaseSchema.table('table_1').column('column_2').type('varchar');
},
{ desc: 'Renaming for testing purposes' }
);