mirror of
https://github.com/ilyakooo0/reshape.git
synced 2024-11-22 17:26:33 +03:00
Add primary key to schema
We need to know the primary key to perform efficient batch updates.
This commit is contained in:
parent
78d8aabd5b
commit
e27be94619
@ -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(),
|
||||
|
@ -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,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user