You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is able to analyse a schema and generate a `settings/schema.jsonc` which will be used to generate accurate data. It does its best to handle foreign keys.
3
5
You can provide a `settings/schema_custom.jsonc` to customize `settings/schema.jsonc` during the generation phase. This will allow you to override datatype for a column, force the use of a foreign key
4
6
or specify a list of values.
5
7
6
8
## functionalities
7
9
8
-
-analyse a table and generate a schema
9
-
-allow for customization on data types, foreign keys, values, uniqueness etc.
10
-
-handle foreign keys
11
-
-define a number of rows to generate per table
12
-
-specify a seed to always generate the same dataset
13
-
-disable/enable triggers during process
10
+
- analyse a table and generate a schema
11
+
- allow for customization on data types, foreign keys, values, uniqueness etc.
12
+
- handle foreign keys
13
+
- define a number of rows to generate per table
14
+
- specify a seed to always generate the same dataset
15
+
- disable/enable triggers during process
14
16
15
17
## 1. Analysis
16
18
17
19
The first step is to analyse your database to generate a `settings/schema.jsonc` by providing database credentials:
18
20
19
21
The `schema` parameter allows you to specify a name for the output files and differentiate between multiple schemas and setups.
@@ -37,34 +41,36 @@ As they will be run every time the generation is launched you have to take care
37
41
38
42
For every tables listed in `settings/schema.jsonc`, the tool will:
39
43
40
-
-get the values of foreign keys if needed
41
-
-generate batches of 1000 rows
42
-
-insert rows until it reaches the defined table limit
43
-
-columns in table are ordered accordingly to your custom schema so you can rely on other column value in the same row.
44
+
- get the values of foreign keys if needed
45
+
- generate batches of 1000 rows
46
+
- insert rows until it reaches the defined table limit
47
+
- columns in table are ordered accordingly to your custom schema so you can rely on other column value in the same row.
44
48
45
49
Available options in `schema_custom.json`:
46
50
47
-
-`settings`: Global settings
48
-
-`disableTriggers: boolean` // disable triggers per table during process and recreate them afterward
49
-
-`engine: "MariaDB"` // only MariaDB is supported for the time being but it should also be compatible with MySQL.
50
-
-`ignoredTables: string[]` // list of table name that should not be analysed nor filled
51
-
-`options: Array<[key: string]: any[]>` // an array of column options to configure specific generators for the whole file `generator` is an array of string to allow multiple settings at once
52
-
-`maxLengthValue: number?` // Hard limit of the maximum number of characters in `string` column type. This will override your custom column `max` value if it's bigger than `maxLengthValue`.
53
-
-`seed: number` // The seed used by the random generator. This is optional. filling process.
54
-
-`tablesToFill: string[]` // list of table name that should be analysed and filled. You can set this parameter or `ignoredTables` depending on the number of table to work with
55
-
-`values: [key: string]: any[]` // an object of user defined array of values
56
-
-`tables: Table[]` // list of tables handled by the tool
57
-
-`Table.name: string` // table name
58
-
-`Table.lines: number` // Deprecated in favor of maxLines
59
-
-`Table.maxLines: number` // Maximum number of rows this table should contains
60
-
-`Table.addLines: number` // Number of rows to be inserted on a single run. The number of lines resulting in the table will not exceed `Table.maxLines`
61
-
-`Table.columns: Column[]` // list of columns handled by the tool
62
-
-`Column.name: string` // column name
63
-
-`Column.generator: bit | boolean | date | foreignKey | integer | real | time | string | values | function` // data type generator used for this column
64
-
-`Column.[key: string]: any[]` // list of options for this column
65
-
-`Column.foreignKey: { table: string, column: string, where: string }` // link to the table.column referenced by this foreign key. A custom clause can ba added to filter value from the foreign column
66
-
-`Column.values: string | any[] | { [key: string]: number }`
51
+
-`settings`: Global settings
52
+
-`disableTriggers: boolean` // disable triggers per table during process and recreate them afterward
53
+
-`engine: "MariaDB"` // only MariaDB is supported for the time being but it should also be compatible with MySQL.
54
+
-`ignoredTables: string[]` // list of table name that should not be analysed nor filled
55
+
-`options: Array<[key: string]: any[]>` // an array of column options to configure specific generators for the whole file `generator` is an array of string to allow multiple settings at once
56
+
-`maxLengthValue: number?` // Hard limit of the maximum number of characters in `string` column type. This will override your custom column `max` value if it's bigger than `maxLengthValue`.
57
+
-`seed: number` // The seed used by the random generator. This is optional. filling process.
58
+
-`tablesToFill: string[]` // list of table name that should be analysed and filled. You can set this parameter or `ignoredTables` depending on the number of table to work with
59
+
-`values: [key: string]: any[]` // an object of user defined array of values
60
+
-`tables: Table[]` // list of tables handled by the tool
61
+
-`Table.name: string` // table name
62
+
-`Table.lines: number` // Deprecated in favor of maxLines
63
+
-`Table.maxLines: number` // Maximum number of rows this table should contains
64
+
-`Table.addLines: number` // Number of rows to be inserted on a single run. The number of lines resulting in the table will not exceed `Table.maxLines`
65
+
-`Table.columns: Column[]` // list of columns handled by the tool
66
+
-`Column.name: string` // column name
67
+
-`Column.generator: bit | boolean | date | foreignKey | integer | real | time | string | values | function | faker` // data type generator used for this column
68
+
-`Column.[key: string]: any[]` // list of options for this column
69
+
-`Column.foreignKey: { table: string, column: string, where: string }` // link to the table.column referenced by this foreign key. A custom clause can ba added to filter value from the foreign column
70
+
-`Column.values: string | any[] | { [key: string]: number }`
67
71
// Name of the list of values to use for this column.
68
72
// You can also directly specify an array of strings for values.
69
73
// Or you can use an object to specify a ratio per value. Ratio will be a number between 0 and 1.
70
-
-`Column.customFunction: (rowIndex: number, row: { [key: string]: string | number }` // a string representing a javascript custom function. It will receive the row index and the full row as arguments.
74
+
-`Column.customFunction: (rowIndex: number, row: { [key: string]: string | number }` // a string representing a javascript custom function. It will receive the row index and the full row as arguments.
75
+
-`Column.template: string` // a template string for `faker` generator. See [fakerjs](https://www.npmjs.com/package/@faker-js/faker) for more information.
76
+
-`Column.locale: string` // locale used by the faker generator.
0 commit comments