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
Copy file name to clipboardExpand all lines: docs/schema-definition.md
+21-11
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,7 @@ return [
30
30
return $faker->safeEmail;
31
31
});
32
32
$table->mask('password');
33
-
})
34
-
->schemaOnly('failed_jobs')
35
-
->schemaOnly('password_resets'),
33
+
}),
36
34
];
37
35
```
38
36
@@ -48,20 +46,18 @@ return [
48
46
];
49
47
```
50
48
51
-
## Dumping table schemas only
49
+
## Exclude specific tables from dumps
52
50
53
-
For certain tables, you do not need to dump the data, but only need the structure of the table itself - like a `password_reset` table. To instruct the masked dumper to only dump the schema, you may use the `schemaOnly` method:
51
+
The `exclude()` method allows you to exclude specific tables from the dump. This can be useful if you want to exclude certain tables from the dump:
54
52
55
53
```php
56
54
return [
57
55
'default' => DumpSchema::define()
58
-
->allTables()
59
-
->schemaOnly('password_resets'),
56
+
->allTables()
57
+
->exclude('password_resets'),
60
58
];
61
59
```
62
60
63
-
This configuration will dump all of your tables - but for the `password_resets` table, it will not create any `INSERT` statements and only dumps the schema of this table.
64
-
65
61
## Masking table column content
66
62
67
63
To mask the content of a given table column, you can use the `mask` method on a custom table definition. For example, let's mask the `password` column on our `users` table:
@@ -106,7 +102,6 @@ This configuration will dump all users and replace their name with "John Doe".
106
102
To gain more flexibility over the replacement, you can pass a function as the second argument. This function receives a Faker instance, as well as the original value of the column:
107
103
108
104
```php
109
-
110
105
return [
111
106
'default' => DumpSchema::define()
112
107
->table('users', function (TableDefinition $table) {
@@ -119,6 +114,21 @@ return [
119
114
120
115
When dumping your data, the dump will now contain a safe, randomly generated email address for every user.
121
116
117
+
## Optimizing large datasets
118
+
119
+
The method TableDefinition::outputInChunksOf(int $chunkSize) allows for chunked inserts for large datasets,
120
+
improving performance and reducing memory consumption during the dump process.
121
+
122
+
```php
123
+
return [
124
+
'default' => DumpSchema::define()
125
+
->allTables()
126
+
->table('users', function($table) {
127
+
return $table->outputInChunksOf(3);
128
+
});
129
+
];
130
+
```
131
+
122
132
## Specifying the database connection to use
123
133
124
134
By default, this package will use your `default` database connection when dumping the tables.
0 commit comments