Repository: typeorm/typeorm
File: src/driver/sap/SapQueryRunner.ts (TypeScript)

Code before:

        upQueries.push(this.createTableSql(table, createForeignKeys))
        downQueries.push(this.dropTableSql(table))

        // if createForeignKeys is true, we must drop created foreign keys in down query.
        // createTable does not need separate method to create foreign keys, because it create fk's in the same query with table creation.
        if (createForeignKeys)
            table.foreignKeys.forEach((foreignKey) =>
                downQueries.push(this.dropForeignKeySql(table, foreignKey)),
            )

        if (createIndices) {
            table.indices.forEach((index) => {
                // new index may be passed without name. In this case we generate index name manually.
                if (!index.name)
                    index.name = this.connection.namingStrategy.indexName(
                        table,
                        index.columnNames,
                        index.where,
                    )
                upQueries.push(this.createIndexSql(table, index))
                downQueries.push(this.dropIndexSql(table, index))
            })
        }

        if (table.comment) {
            upQueries.push(
                new Query(
                    `COMMENT ON TABLE ${this.escapePath(table)}
                    IS ${this.escapeComment(table.comment)}`,
                ),
            )
            downQueries.push(
                new Query(
                    `COMMENT ON TABLE ${this.escapePath(table)}
                    IS NULL`,
                ),
            )
        }

        await this.executeQueries(upQueries, downQueries)
    }

    /**
     * Drops the table.
     */
    async dropTable(
        tableOrName: Table | string,
        ifExist?: boolean,
        dropForeignKeys: boolean = true,
        dropIndices: boolean = true,

Review comment (suggestion):
No need for an additional query, can be done directly in `CREATE TABLE`: https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/create-table-statement-data-definition#loio20d58a5f75191014b2fe92141b7df228__table_comment_string

Code after:
            )
            exist = !!result.length
        }
        if (!ifExist || (ifExist && exist)) {
            const up = `DROP SCHEMA "${schema}" ${isCascade ? "CASCADE" : ""}`
            const down = `CREATE SCHEMA "${schema}"`
            await this.executeQueries(new Query(up), new Query(down))
        }
    }

    /**
     * Creates a new table.
     * @param table
     * @param ifNotExist
     * @param createForeignKeys
     * @param createIndices
     */
    async createTable(
        table: Table,
        ifNotExist: boolean = false,
        createForeignKeys: boolean = true,
        createIndices: boolean = true,
    ): Promise<void> {
        if (ifNotExist) {
            const isTableExist = await this.hasTable(table)
            if (isTableExist) return Promise.resolve()
        }
        const upQueries: Query[] = []
        const downQueries: Query[] = []

        upQueries.push(this.createTableSql(table, createForeignKeys))
        downQueries.push(this.dropTableSql(table))

        // if createForeignKeys is true, we must drop created foreign keys in down query.
        // createTable does not need separate method to create foreign keys, because it create fk's in the same query with table creation.
        if (createForeignKeys)
            table.foreignKeys.forEach((foreignKey) =>
                downQueries.push(this.dropForeignKeySql(table, foreignKey)),
            )

        if (createIndices) {
            table.indices.forEach((index) => {
                // new index may be passed without name. In this case we generate index name manually.
                if (!index.name)
                    index.name = this.connection.namingStrategy.indexName(
                        table,
                        index.columnNames,
                        index.where,
                    )
                upQueries.push(this.createIndexSql(table, index))
                downQueries.push(this.dropIndexSql(table, index))