Add primary key to schema

We need to know the primary key to perform efficient batch updates.
This commit is contained in:
fabianlindfors 2021-11-08 23:49:49 +01:00
parent 78d8aabd5b
commit e27be94619
2 changed files with 4 additions and 0 deletions

View File

@ -75,6 +75,8 @@ impl Action for CreateTable {
fn update_schema(&self, schema: &mut Schema) -> anyhow::Result<()> {
let mut table = Table::new(self.name.to_string());
table.primary_key = self.primary_key.clone();
for column in &self.columns {
table.add_column(crate::schema::Column {
name: column.name.to_string(),

View File

@ -42,6 +42,7 @@ impl Default for Schema {
pub struct Table {
pub name: String,
pub columns: Vec<Column>,
pub primary_key: Vec<String>,
#[serde(skip)]
pub has_is_new: bool,
}
@ -50,6 +51,7 @@ impl Table {
pub fn new(name: impl Into<String>) -> Table {
Table {
name: name.into(),
primary_key: vec![],
columns: vec![],
has_is_new: false,
}