deno.land / x / pg_mem@2.8.1 / execution / schema-amends / create-schema.ts

create-schema.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { _Transaction, asTable, _ISchema, NotSupported, CreateIndexColDef, _ITable, CreateIndexDef, _IStatement, _IStatementExecutor, QueryError } from '../../interfaces-private.ts';import { CreateSchemaStatement } from 'https://deno.land/x/pgsql_ast_parser@12.0.1/mod.ts';import { ExecHelper } from '../exec-utils.ts';import { ignore } from '../../utils.ts';
export class CreateSchema extends ExecHelper implements _IStatementExecutor { private toCreate?: string;
constructor(private st: _IStatement, p: CreateSchemaStatement) { super(p); const sch = this.st.schema.db.getSchema(p.name.name, true); if (!p.ifNotExists && sch) { throw new QueryError('schema already exists! ' + p.name); } if (sch) { ignore(p); } else { this.toCreate = p.name.name; } }
execute(t: _Transaction) { // commit pending data before making changes // (because does not support further rollbacks) t = t.fullCommit();
// create schema if (this.toCreate) { this.st.schema.db.createSchema(this.toCreate); }
// new implicit transaction t = t.fork(); return this.noData(t, 'CREATE'); }}
pg_mem

Version Info

Tagged at
a year ago