Search code examples
rustrust-diesel

Is it possible to generate Diesel schema for only specific tables?


I am using Diesel to generate some schema using this command from the Getting Started guide:

diesel migration run

Is it possible to only generate one table? Some of my tables do not have a primary key. And for development purposes, I want to use just one table right now, I don't need to generate the schema for all tables.


Solution

  • From Configuring Diesel CLI, create a diesel.toml file in the same folder as Cargo.toml. With that file, you can configure Diesel it like so:

    [print_schema]
    filter = { only_tables = ["dashboard", "admin_users"] }
    

    You can then rerun the diesel migration run command.