drizzle-seed uses versioning to manage outputs for static and dynamic data. To ensure true
determinism, ensure that values remain unchanged when using the same seed number. If changes are made to
static data sources or dynamic data generation logic, the version will be updated, allowing
you to choose between sticking with the previous version or using the latest.
You can upgrade to the latest drizzle-seed version for new features, such as additional
generators, while maintaining deterministic outputs with a previous version if needed. This
is particularly useful when you need to rely on existing deterministic data while accessing new functionality.
await seed(db, schema, { version: '2' });
History
api version
npm version
Changed generators
v1
0.1.1
v2
0.2.1
string(), interval({ isUnique: true })
v3
0.4.0
hash generating function
v4 (LTS)
1.0.0-beta.8
uuid
How it works under the hood?
This is not an actual API change; it is just an example of how we will proceed with drizzle-seed versioning.
For example, lastName generator was changed, and new version, V2, of this generator became available.
Later, firstName generator was changed, making V3 version of this generator available.
V1
V2
V3(latest)
LastNameGen
LastNameGenV1
LastNameGenV2
FirstNameGen
FirstNameGenV1
FirstNameGenV3
Use the firstName generator of version 3 and the lastName generator of version 2
await seed(db, schema);
If you are not ready to use latest generator version right away, you can specify max version to use
Use the firstName generator of version 1 and the lastName generator of version 2
await seed(db, schema, { version: '2' });
Use the firstName generator of version 1 and the lastName generator of version 1.
await seed(db, schema, { version: '1' });
Version 2
Unique interval generator was changed
Reason for upgrade
An older version of the generator could produce intervals like 1 minute 60 seconds and 2 minutes 0 seconds, treating them as distinct intervals.
However, when the 1 minute 60 seconds interval is inserted into a SQLite database, it is automatically converted to 2 minutes 0 seconds. As a result, attempting to insert the 2 minutes 0 seconds interval into a unique column afterwards will cause an error
You will be affected, if you use the unique interval generator in your seeding script, as shown in the script below:
The previous version of the hash generating function generated different hashes depending on whether Bun or Node.js was used, and hashes also varied across versions of Node.js.
The new hash generating function will generate the same hash regardless of the version of Node.js or Bun, resulting in deterministic data generation across all versions.
All generators will output different values compared to the previous version, even with the same seed number.
The previous version of hash generating function is v1.
await seed(db, schema, { version: '1' });
To use the v2 generators while maintaining the v1 hash generating function:
await seed(db, schema, { version: '2' });
Version 4
uuid generator was changed
Reason to upgrade
UUID values generated by the old version of the uuid generator fail Zod’s v4 UUID validation.
example
import { createSelectSchema } from 'drizzle-zod';import { seed } from 'drizzle-seed';await seed(db, { uuidTest: schema.uuidTest }, { count: 1 }).refine((funcs) => ({ uuidTest: { columns: { col1: funcs.uuid() } } }));const uuidSelectSchema = createSelectSchema(schema.uuidTest);const res = await db.select().from(schema.uuidTest);// the line below will throw an error when using old version of uuid generatoruuidSelectSchema.parse(res[0]);