Files
2025-11-30 08:23:07 +08:00

104 lines
3.4 KiB
JSON

{
"_comment": "Template for defining test data schemas. Use this as a starting point for creating your test data definitions.",
"schema_name": "your_schema_name",
"_comment": "The name of the database schema this data applies to. Often 'public'.",
"tables": [
{
"table_name": "users",
"_comment": "The name of the table.",
"columns": [
{
"column_name": "id",
"data_type": "INTEGER",
"primary_key": true,
"auto_increment": true,
"_comment": "Example of an integer primary key with auto-increment."
},
{
"column_name": "username",
"data_type": "VARCHAR(255)",
"nullable": false,
"unique": true,
"faker": "user_name",
"_comment": "Example using Faker to generate usernames."
},
{
"column_name": "email",
"data_type": "VARCHAR(255)",
"nullable": false,
"unique": true,
"faker": "email",
"_comment": "Example using Faker to generate email addresses."
},
{
"column_name": "created_at",
"data_type": "TIMESTAMP",
"default": "CURRENT_TIMESTAMP",
"_comment": "Example of a timestamp column with a default value."
}
],
"rows": [
{
"username": "existing_user",
"email": "existing@example.com",
"_comment": "Optionally specify exact values for specific rows. Faker will be used if not specified"
}
]
},
{
"table_name": "products",
"_comment": "Example of another table.",
"columns": [
{
"column_name": "id",
"data_type": "INTEGER",
"primary_key": true,
"auto_increment": true
},
{
"column_name": "name",
"data_type": "VARCHAR(255)",
"nullable": false,
"faker": "product_name",
"_comment": "Using a custom Faker provider. Requires the provider to be installed."
},
{
"column_name": "price",
"data_type": "DECIMAL(10, 2)",
"nullable": false,
"faker": "pyfloat:left_digits=3,right_digits=2,positive=True",
"_comment": "Example of using pyfloat for generating prices. Can use faker.pyfloat arguments."
},
{
"column_name": "description",
"data_type": "TEXT",
"faker": "paragraph",
"_comment": "Example of using faker to generate a paragraph of text."
},
{
"column_name": "user_id",
"data_type": "INTEGER",
"nullable": false,
"foreign_key": "users.id",
"_comment": "Example of a foreign key relationship. Requires the 'users' table to exist and have an 'id' column."
}
],
"rows": [
{
"name": "Specific Product",
"price": 99.99,
"description": "A very specific product description.",
"user_id": 1
}
]
}
],
"options": {
"number_of_rows_per_table": 5,
"_comment": "Default number of rows to create for each table if no 'rows' key is specified. Defaults to 1 if not specified.",
"rollback_transaction": true,
"_comment": "Whether to rollback the transaction after the data is inserted. Defaults to true.",
"truncate_tables": false,
"_comment": "Whether to truncate the tables before inserting data. Defaults to false."
}
}