2

I'm trying to see how the TableCreateStatement should be called and where in my code it should live. Looking at the documentation no idea really.

I see I can create a table manually with:

let stmt = sea_query::Table::create()
        .table(super::post::Entity)
        .if_not_exists()
        .col(

but I already have copy-pasted together a pub struct Model and I would like to not repeat myself there.

Alper
  • 3,424
  • 4
  • 39
  • 45

1 Answers1

1

After hunting together through some documentation, this checks out:

let backend = conn.get_database_backend();
let schema = Schema::new(backend);
let table_create_statement = schema.create_table_from_entity(FoursquareGmapsMappings);
let table_create_result = conn.execute(backend.build(&table_create_statement)).await;
Alper
  • 3,424
  • 4
  • 39
  • 45