Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Migrate
createSchema()
to TypeScript (#15339)
* Initial refactorings of query-interface.d.ts interfaces to files Created constructor and initial typings for AbstractQueryInterface * Add createSchema to AbstractQueryInterfaceTypeScript * QueryInterface should pass options through to queryGenerator * Avoid InvalidOptionReceivedErrors on dialects that don't support collate/charset * Move QueryInterface types to a separate file
- Loading branch information
1 parent
a9f2223
commit a3d164f
Showing
23 changed files
with
127 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { Sequelize } from '../../sequelize'; | ||
import type { AbstractQueryGenerator } from './query-generator'; | ||
import type { CreateSchemaOptions, QueryInterfaceOptions } from './query-interface.types'; | ||
|
||
export class AbstractQueryInterfaceTypeScript { | ||
readonly sequelize: Sequelize; | ||
readonly queryGenerator: AbstractQueryGenerator; | ||
|
||
constructor(options: QueryInterfaceOptions) { | ||
this.sequelize = options.sequelize; | ||
this.queryGenerator = options.queryGenerator; | ||
} | ||
|
||
/** | ||
* Creates a new database schema. | ||
* | ||
* **Note:** this is a schema in the [postgres sense of the word](http://www.postgresql.org/docs/9.1/static/ddl-schemas.html), | ||
* not a database table. In mysql and sqlite, this command will do nothing. | ||
* | ||
* @param schema | ||
* @param options | ||
*/ | ||
async createSchema(schema: string, options?: CreateSchemaOptions): Promise<void> { | ||
const sql = this.queryGenerator.createSchemaQuery(schema, options); | ||
await this.sequelize.queryRaw(sql, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { QueryRawOptions, Sequelize } from '../../sequelize'; | ||
import type { AbstractQueryGenerator, CreateSchemaQueryOptions } from './query-generator'; | ||
|
||
export interface QueryInterfaceOptions { | ||
sequelize: Sequelize; | ||
queryGenerator: AbstractQueryGenerator; | ||
} | ||
|
||
/** Options accepted by {@link AbstractQueryInterfaceTypeScript#createSchema} */ | ||
export interface CreateSchemaOptions extends CreateSchemaQueryOptions, QueryRawOptions {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.