@itrocks/schema-to-mysql 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +280 -0
- package/package.json +11 -13
- package/esm/schema-to-mysql.d.ts +0 -15
- package/esm/schema-to-mysql.js +0 -104
package/README.md
CHANGED
|
@@ -7,3 +7,283 @@
|
|
|
7
7
|
# schema-to-mysql
|
|
8
8
|
|
|
9
9
|
Converts a table schema into MySQL statements for table creation.
|
|
10
|
+
|
|
11
|
+
*This documentation was written by an artificial intelligence and may contain errors or approximations.
|
|
12
|
+
It has not yet been fully reviewed by a human. If anything seems unclear or incomplete,
|
|
13
|
+
please feel free to contact the author of this package.*
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i @itrocks/schema-to-mysql @itrocks/schema
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`@itrocks/schema-to-mysql` has no runtime dependency on MySQL itself. It only needs
|
|
22
|
+
the `@itrocks/schema` package, which provides the in-memory representation of
|
|
23
|
+
tables, columns, and indexes.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
`@itrocks/schema-to-mysql` exposes a single class, `SchemaToMysql`. It converts
|
|
28
|
+
`Table`, `Column`, `Index`, and `Type` definitions from `@itrocks/schema` into
|
|
29
|
+
MySQL `CREATE TABLE` statements.
|
|
30
|
+
|
|
31
|
+
This package is typically used together with:
|
|
32
|
+
|
|
33
|
+
- `@itrocks/reflect-to-schema` to generate `Table` objects from TypeScript
|
|
34
|
+
classes.
|
|
35
|
+
- `@itrocks/mysql-to-schema` to introspect existing database tables.
|
|
36
|
+
- `@itrocks/schema-diff` / `@itrocks/schema-diff-mysql` to generate ALTER
|
|
37
|
+
statements from schema diffs.
|
|
38
|
+
|
|
39
|
+
### Minimal example: generate a CREATE TABLE statement
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { SchemaToMysql } from '@itrocks/schema-to-mysql'
|
|
43
|
+
import type { Column, Table } from '@itrocks/schema'
|
|
44
|
+
|
|
45
|
+
const userTable: Table = {
|
|
46
|
+
name: 'user',
|
|
47
|
+
charset: 'utf8mb4',
|
|
48
|
+
collation: 'utf8mb4_unicode_ci',
|
|
49
|
+
engine: 'InnoDB',
|
|
50
|
+
columns: [
|
|
51
|
+
{
|
|
52
|
+
name: 'id',
|
|
53
|
+
type: { name: 'integer', signed: false, maxValue: 10_000 },
|
|
54
|
+
canBeNull: false,
|
|
55
|
+
autoIncrement: true,
|
|
56
|
+
} as Column,
|
|
57
|
+
{
|
|
58
|
+
name: 'email',
|
|
59
|
+
type: { name: 'string', length: 255, variableLength: true },
|
|
60
|
+
canBeNull: false,
|
|
61
|
+
} as Column,
|
|
62
|
+
],
|
|
63
|
+
indexes: [
|
|
64
|
+
{
|
|
65
|
+
name: 'PRIMARY',
|
|
66
|
+
type: 'primary',
|
|
67
|
+
keys: [ { columnName: 'id' } ],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'UNIQ_user_email',
|
|
71
|
+
type: 'unique',
|
|
72
|
+
keys: [ { columnName: 'email' } ],
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const schemaToMysql = new SchemaToMysql()
|
|
78
|
+
const sql = schemaToMysql.sql(userTable)
|
|
79
|
+
|
|
80
|
+
console.log(sql)
|
|
81
|
+
// CREATE TABLE `user` (
|
|
82
|
+
// `id` bigint unsigned NOT NULL AUTO_INCREMENT,
|
|
83
|
+
// `email` varchar(255) NOT NULL,
|
|
84
|
+
// PRIMARY KEY (`id`),
|
|
85
|
+
// UNIQUE KEY `UNIQ_user_email` (`email`)
|
|
86
|
+
// ) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE InnoDB
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
You can then execute the generated SQL using your preferred MySQL/MariaDB
|
|
90
|
+
driver.
|
|
91
|
+
|
|
92
|
+
### Complete example: keep a table in sync with a TypeScript model
|
|
93
|
+
|
|
94
|
+
In real applications, you will rarely build `Table` objects by hand. Instead,
|
|
95
|
+
you typically:
|
|
96
|
+
|
|
97
|
+
1. Define your domain model as TypeScript classes.
|
|
98
|
+
2. Convert those classes to a `Table` definition using
|
|
99
|
+
`@itrocks/reflect-to-schema`.
|
|
100
|
+
3. Convert the `Table` to a `CREATE TABLE` SQL statement using
|
|
101
|
+
`SchemaToMysql`.
|
|
102
|
+
4. Optionally combine with `@itrocks/mysql-to-schema` and
|
|
103
|
+
`@itrocks/schema-diff-mysql` to migrate existing databases.
|
|
104
|
+
|
|
105
|
+
Below is a simplified example showing how `SchemaToMysql` integrates in a
|
|
106
|
+
schema-management flow similar to what `@itrocks/mysql-maintainer` does
|
|
107
|
+
internally:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import mariadb from 'mariadb'
|
|
111
|
+
import type { Connection } from 'mariadb'
|
|
112
|
+
import { ReflectToTable } from '@itrocks/reflect-to-schema'
|
|
113
|
+
import { SchemaToMysql } from '@itrocks/schema-to-mysql'
|
|
114
|
+
|
|
115
|
+
class User {
|
|
116
|
+
id!: number
|
|
117
|
+
email!: string
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function createUserTableIfMissing(connection: Connection) {
|
|
121
|
+
const reflectToTable = new ReflectToTable()
|
|
122
|
+
const userTable = reflectToTable.convert(User)
|
|
123
|
+
|
|
124
|
+
const schemaToMysql = new SchemaToMysql()
|
|
125
|
+
const sql = schemaToMysql.sql(userTable)
|
|
126
|
+
|
|
127
|
+
// In a real-world scenario you would first check whether the table exists.
|
|
128
|
+
await connection.query(sql)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function main() {
|
|
132
|
+
const pool = mariadb.createPool({
|
|
133
|
+
host: 'localhost',
|
|
134
|
+
user: 'root',
|
|
135
|
+
password: 'secret',
|
|
136
|
+
database: 'my_app',
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
const connection = await pool.getConnection()
|
|
140
|
+
try {
|
|
141
|
+
await createUserTableIfMissing(connection)
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
connection.release()
|
|
145
|
+
await pool.end()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
main().catch(console.error)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## API
|
|
153
|
+
|
|
154
|
+
### `class SchemaToMysql`
|
|
155
|
+
|
|
156
|
+
Converts schema objects from `@itrocks/schema` into MySQL SQL strings. All
|
|
157
|
+
methods are pure helpers: they do not perform any database I/O.
|
|
158
|
+
|
|
159
|
+
You will usually only need the high-level `sql(table)` method, but the other
|
|
160
|
+
helpers can be useful when you need fine-grained control over the generated
|
|
161
|
+
statements.
|
|
162
|
+
|
|
163
|
+
#### `columnSql(column: Column): string`
|
|
164
|
+
|
|
165
|
+
Builds the SQL fragment describing a single column, for use inside a
|
|
166
|
+
`CREATE TABLE` statement.
|
|
167
|
+
|
|
168
|
+
- `column`: a `Column` object from `@itrocks/schema`.
|
|
169
|
+
|
|
170
|
+
The method uses the column's `type`, `canBeNull`, `default`,
|
|
171
|
+
`autoIncrement`, and optionally `type.collate` (for `enum`, `string`, and
|
|
172
|
+
`set` types) to build a valid MySQL column definition.
|
|
173
|
+
|
|
174
|
+
#### `columnsSql(columns: Column[]): string`
|
|
175
|
+
|
|
176
|
+
Builds the comma-separated list of column definitions for a table. Internally
|
|
177
|
+
delegates to `columnSql` for each element.
|
|
178
|
+
|
|
179
|
+
- `columns`: array of `Column` objects.
|
|
180
|
+
|
|
181
|
+
Returns a multiline string with one column definition per line, separated by
|
|
182
|
+
commas, suitable for inclusion inside `CREATE TABLE (...)`.
|
|
183
|
+
|
|
184
|
+
#### `defaultSql(value: any): string`
|
|
185
|
+
|
|
186
|
+
Converts a JavaScript value into a SQL literal suitable for use in a
|
|
187
|
+
`DEFAULT` clause.
|
|
188
|
+
|
|
189
|
+
- `value`: the default value to serialize.
|
|
190
|
+
|
|
191
|
+
Behavior:
|
|
192
|
+
|
|
193
|
+
- `null` becomes `NULL`.
|
|
194
|
+
- `string` values are quoted and single quotes are escaped.
|
|
195
|
+
- `Date` values are formatted as `YYYY-MM-DD` or `YYYY-MM-DD HH:MM:SS`.
|
|
196
|
+
- Any other value is converted using JavaScript string coercion.
|
|
197
|
+
|
|
198
|
+
You rarely need to call this directly; it is used by `columnSql` when
|
|
199
|
+
`column.default` is defined.
|
|
200
|
+
|
|
201
|
+
#### `indexSql(index: Index): string`
|
|
202
|
+
|
|
203
|
+
Builds the SQL fragment describing a single index.
|
|
204
|
+
|
|
205
|
+
- `index`: an `Index` object from `@itrocks/schema`.
|
|
206
|
+
|
|
207
|
+
Depending on `index.type`, this produces:
|
|
208
|
+
|
|
209
|
+
- `PRIMARY KEY (...)` for primary indexes.
|
|
210
|
+
- `UNIQUE KEY \\`name\\` (...)` for unique indexes.
|
|
211
|
+
- `KEY \\`name\\` (...)` for regular (non-unique) indexes.
|
|
212
|
+
|
|
213
|
+
Column lengths defined on index keys are respected.
|
|
214
|
+
|
|
215
|
+
#### `indexesSql(indexes: Index[]): string`
|
|
216
|
+
|
|
217
|
+
Builds the comma-separated list of index definitions for a table.
|
|
218
|
+
|
|
219
|
+
- `indexes`: array of `Index` objects.
|
|
220
|
+
|
|
221
|
+
Returns a multiline string suitable for inclusion after the column
|
|
222
|
+
definitions inside `CREATE TABLE (...)`.
|
|
223
|
+
|
|
224
|
+
#### `sql(table: Table): string`
|
|
225
|
+
|
|
226
|
+
Generates the full `CREATE TABLE` statement for a given table.
|
|
227
|
+
|
|
228
|
+
- `table`: a `Table` object from `@itrocks/schema`.
|
|
229
|
+
|
|
230
|
+
The result combines:
|
|
231
|
+
|
|
232
|
+
- `tableSql(table)` for the `CREATE TABLE` header,
|
|
233
|
+
- `columnsSql(table.columns)` for the column list,
|
|
234
|
+
- `indexesSql(table.indexes)` for the index list,
|
|
235
|
+
- `tableSqlEnd(table)` for charset, collation, and engine.
|
|
236
|
+
|
|
237
|
+
#### `tableSql(table: Table): string`
|
|
238
|
+
|
|
239
|
+
Returns the beginning of a `CREATE TABLE` statement for the given table:
|
|
240
|
+
`CREATE TABLE \\`<name>\\``.
|
|
241
|
+
|
|
242
|
+
You generally do not need to call this directly unless you are assembling your
|
|
243
|
+
own custom DDL.
|
|
244
|
+
|
|
245
|
+
#### `tableSqlEnd(table: Table): string`
|
|
246
|
+
|
|
247
|
+
Returns the trailing part of the `CREATE TABLE` statement, including:
|
|
248
|
+
|
|
249
|
+
- `CHARSET <table.charset>`
|
|
250
|
+
- `COLLATE <table.collation>`
|
|
251
|
+
- `ENGINE <table.engine>`
|
|
252
|
+
|
|
253
|
+
This method assumes that `charset`, `collation`, and `engine` are set on the
|
|
254
|
+
`Table` object.
|
|
255
|
+
|
|
256
|
+
#### `typeSql(type: Type): string`
|
|
257
|
+
|
|
258
|
+
Translates a `Type` object into a MySQL column type.
|
|
259
|
+
|
|
260
|
+
- `type`: a `Type` object from `@itrocks/schema`.
|
|
261
|
+
|
|
262
|
+
Behavior overview:
|
|
263
|
+
|
|
264
|
+
- For `decimal`, uses `decimal(length, precision)`.
|
|
265
|
+
- For `integer`, chooses between `tinyint`, `smallint`, `mediumint`, `int`,
|
|
266
|
+
and `bigint` based on `length` or `maxValue`, and respects `signed`.
|
|
267
|
+
- For `string`, chooses between `char`, `varchar`, `text`, `mediumtext`, and
|
|
268
|
+
`longtext` based on `length` and `variableLength`.
|
|
269
|
+
- For other names (including `enum`, `set`, etc.), uses the raw `name`.
|
|
270
|
+
- Appends `unsigned` when `signed === false`.
|
|
271
|
+
- Appends `ZEROFILL` when `zeroFill` is true.
|
|
272
|
+
|
|
273
|
+
Again, you generally do not need to call this directly unless you are
|
|
274
|
+
constructing your own SQL from low-level pieces.
|
|
275
|
+
|
|
276
|
+
## Typical use cases
|
|
277
|
+
|
|
278
|
+
- **Initial schema creation**: Generate `CREATE TABLE` statements from a set of
|
|
279
|
+
`Table` objects and run them on a fresh MySQL/MariaDB database.
|
|
280
|
+
- **Code-first development**: Describe your domain model as TypeScript
|
|
281
|
+
classes, convert them with `@itrocks/reflect-to-schema`, then feed the
|
|
282
|
+
resulting `Table` objects to `SchemaToMysql`.
|
|
283
|
+
- **Schema migration tooling**: Combine `SchemaToMysql` with
|
|
284
|
+
`@itrocks/mysql-to-schema`, `@itrocks/schema-diff`, and
|
|
285
|
+
`@itrocks/schema-diff-mysql` to compute diffs between an existing database
|
|
286
|
+
and your target model, and generate the SQL needed to migrate.
|
|
287
|
+
- **Custom DDL generators**: Reuse the low-level helpers (`columnSql`,
|
|
288
|
+
`indexSql`, `typeSql`, etc.) when you need to generate partial DDL fragments
|
|
289
|
+
or specialized statements beyond a simple `CREATE TABLE`.
|
package/package.json
CHANGED
|
@@ -8,20 +8,17 @@
|
|
|
8
8
|
},
|
|
9
9
|
"description": "Converts a table schema into MySQL statements for table creation",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"typescript": "
|
|
11
|
+
"typescript": "^6.0"
|
|
12
12
|
},
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": ">=
|
|
15
|
-
},
|
|
16
|
-
"exports": {
|
|
17
|
-
"import": "./esm/schema-to-mysql.js",
|
|
18
|
-
"require": "./cjs/schema-to-mysql.js"
|
|
14
|
+
"node": ">=24"
|
|
19
15
|
},
|
|
16
|
+
"exports": "./cjs/schema-to-mysql.js",
|
|
20
17
|
"files": [
|
|
21
18
|
"LICENSE",
|
|
22
19
|
"README.md",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
20
|
+
"cjs",
|
|
21
|
+
"!*.map"
|
|
25
22
|
],
|
|
26
23
|
"homepage": "https://it.rocks",
|
|
27
24
|
"keywords": [
|
|
@@ -31,12 +28,16 @@
|
|
|
31
28
|
"database",
|
|
32
29
|
"execute",
|
|
33
30
|
"foreign",
|
|
31
|
+
"generation",
|
|
34
32
|
"index",
|
|
35
33
|
"it.rocks",
|
|
34
|
+
"mariadb",
|
|
36
35
|
"mysql",
|
|
36
|
+
"orm",
|
|
37
37
|
"RDB",
|
|
38
38
|
"relational",
|
|
39
39
|
"schema",
|
|
40
|
+
"sql",
|
|
40
41
|
"structure",
|
|
41
42
|
"table"
|
|
42
43
|
],
|
|
@@ -47,10 +48,7 @@
|
|
|
47
48
|
"url": "git+https://github.com/itrocks-ts/schema-to-mysql.git"
|
|
48
49
|
},
|
|
49
50
|
"scripts": {
|
|
50
|
-
"build": "
|
|
51
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
52
|
-
"build:esm": "tsc -p tsconfig.esm.json"
|
|
51
|
+
"build": "tsc"
|
|
53
52
|
},
|
|
54
|
-
"
|
|
55
|
-
"version": "0.0.5"
|
|
53
|
+
"version": "0.1.0"
|
|
56
54
|
}
|
package/esm/schema-to-mysql.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Column } from '@itrocks/schema';
|
|
2
|
-
import { Index } from '@itrocks/schema';
|
|
3
|
-
import { Table } from '@itrocks/schema';
|
|
4
|
-
import { Type } from '@itrocks/schema';
|
|
5
|
-
export declare class SchemaToMysql {
|
|
6
|
-
columnSql(column: Column): string;
|
|
7
|
-
columnsSql(columns: Column[]): string;
|
|
8
|
-
defaultSql(value: any): string;
|
|
9
|
-
indexSql(index: Index): string;
|
|
10
|
-
indexesSql(indexes: Index[]): string;
|
|
11
|
-
sql(table: Table): string;
|
|
12
|
-
tableSql(table: Table): string;
|
|
13
|
-
tableSqlEnd(table: Table): string;
|
|
14
|
-
typeSql(type: Type): string;
|
|
15
|
-
}
|
package/esm/schema-to-mysql.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
export class SchemaToMysql {
|
|
2
|
-
columnSql(column) {
|
|
3
|
-
return '`' + column.name + '` '
|
|
4
|
-
+ this.typeSql(column.type)
|
|
5
|
-
+ ((column.canBeNull === false) ? ' NOT NULL' : '')
|
|
6
|
-
+ ((column.default !== undefined) ? (' DEFAULT ' + this.defaultSql(column.default)) : '')
|
|
7
|
-
+ (column.autoIncrement ? ' AUTO_INCREMENT' : '')
|
|
8
|
-
+ ((['enum', 'string', 'set'].includes(column.type.name) && column.type.collate)
|
|
9
|
-
? ' COLLATE ' + column.type.collate
|
|
10
|
-
: '');
|
|
11
|
-
}
|
|
12
|
-
columnsSql(columns) {
|
|
13
|
-
return columns.map(column => this.columnSql(column)).join(',\n');
|
|
14
|
-
}
|
|
15
|
-
defaultSql(value) {
|
|
16
|
-
if (value === null) {
|
|
17
|
-
return 'NULL';
|
|
18
|
-
}
|
|
19
|
-
if (typeof value === 'string') {
|
|
20
|
-
return "'" + value.replaceAll("'", "''") + "'";
|
|
21
|
-
}
|
|
22
|
-
if (value instanceof Date) {
|
|
23
|
-
return "'" + value.toISOString().slice(0, (value.getTime() % 864e5) ? 19 : 10).replace('T', ' ') + "'";
|
|
24
|
-
}
|
|
25
|
-
return '' + value;
|
|
26
|
-
}
|
|
27
|
-
indexSql(index) {
|
|
28
|
-
const keysSql = ' ('
|
|
29
|
-
+ index.keys.map(key => '`' + key.columnName + '`' + (key.length ? '(' + key.length + ')' : '')).join(',')
|
|
30
|
-
+ ')';
|
|
31
|
-
return (index.type === 'primary')
|
|
32
|
-
? ('PRIMARY KEY' + keysSql)
|
|
33
|
-
: (((index.type === 'unique') ? 'UNIQUE ' : '') + 'KEY `' + index.name + '`' + keysSql);
|
|
34
|
-
}
|
|
35
|
-
indexesSql(indexes) {
|
|
36
|
-
return indexes.map(index => this.indexSql(index)).join(',\n');
|
|
37
|
-
}
|
|
38
|
-
sql(table) {
|
|
39
|
-
const columnsSql = this.columnsSql(table.columns);
|
|
40
|
-
const indexesSql = this.indexesSql(table.indexes);
|
|
41
|
-
return this.tableSql(table) + ' (\n'
|
|
42
|
-
+ columnsSql
|
|
43
|
-
+ (indexesSql ? ',' + indexesSql : '') + '\n)'
|
|
44
|
-
+ this.tableSqlEnd(table);
|
|
45
|
-
}
|
|
46
|
-
tableSql(table) {
|
|
47
|
-
return 'CREATE TABLE `' + table.name + '`';
|
|
48
|
-
}
|
|
49
|
-
tableSqlEnd(table) {
|
|
50
|
-
return ' CHARSET ' + table.charset
|
|
51
|
-
+ ' COLLATE ' + table.collation
|
|
52
|
-
+ ' ENGINE ' + table.engine;
|
|
53
|
-
}
|
|
54
|
-
typeSql(type) {
|
|
55
|
-
const length = type.length;
|
|
56
|
-
const name = type.name;
|
|
57
|
-
let typeSql;
|
|
58
|
-
switch (name) {
|
|
59
|
-
case 'decimal':
|
|
60
|
-
typeSql = 'decimal(' + type.length + ',' + type.precision + ')';
|
|
61
|
-
break;
|
|
62
|
-
case 'integer':
|
|
63
|
-
const maxValue = type.maxValue;
|
|
64
|
-
if (maxValue !== undefined) {
|
|
65
|
-
if (type.signed) {
|
|
66
|
-
typeSql = (maxValue > 2_147_483_647) ? 'bigint'
|
|
67
|
-
: (maxValue > 8_388_607) ? 'int'
|
|
68
|
-
: (maxValue > 32_767) ? 'mediumint'
|
|
69
|
-
: (maxValue > 127) ? 'smallint'
|
|
70
|
-
: 'tinyint';
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
typeSql = (maxValue > 4_294_967_295) ? 'bigint'
|
|
74
|
-
: (maxValue > 16_777_215) ? 'int'
|
|
75
|
-
: (maxValue > 65_535) ? 'mediumint'
|
|
76
|
-
: (maxValue > 255) ? 'smallint'
|
|
77
|
-
: 'tinyint';
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
typeSql = (length === undefined) ? 'bigint'
|
|
82
|
-
: (length > 9) ? 'bigint'
|
|
83
|
-
: (length > 7) ? 'int'
|
|
84
|
-
: (length > 4) ? 'mediumint'
|
|
85
|
-
: (length > 2) ? 'smallint'
|
|
86
|
-
: 'tinyint';
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
case 'string':
|
|
90
|
-
typeSql = (length === undefined) ? 'longtext'
|
|
91
|
-
: (length > 16_777_215) ? 'longtext'
|
|
92
|
-
: (length > 65_535) ? 'mediumtext'
|
|
93
|
-
: (length > 255) ? 'text'
|
|
94
|
-
: ((type.variableLength ? 'var' : '') + 'char(' + length + ')');
|
|
95
|
-
break;
|
|
96
|
-
default:
|
|
97
|
-
typeSql = name;
|
|
98
|
-
}
|
|
99
|
-
return typeSql
|
|
100
|
-
+ ((type.signed === false) ? ' unsigned' : '')
|
|
101
|
-
+ (type.zeroFill ? ' ZEROFILL' : '');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=schema-to-mysql.js.map
|