mirror of
https://github.com/ilyakooo0/reshape.git
synced 2024-11-26 10:34:12 +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<()> {
|
fn update_schema(&self, schema: &mut Schema) -> anyhow::Result<()> {
|
||||||
let mut table = Table::new(self.name.to_string());
|
let mut table = Table::new(self.name.to_string());
|
||||||
|
table.primary_key = self.primary_key.clone();
|
||||||
|
|
||||||
for column in &self.columns {
|
for column in &self.columns {
|
||||||
table.add_column(crate::schema::Column {
|
table.add_column(crate::schema::Column {
|
||||||
name: column.name.to_string(),
|
name: column.name.to_string(),
|
||||||
|
@ -42,6 +42,7 @@ impl Default for Schema {
|
|||||||
pub struct Table {
|
pub struct Table {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub columns: Vec<Column>,
|
pub columns: Vec<Column>,
|
||||||
|
pub primary_key: Vec<String>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub has_is_new: bool,
|
pub has_is_new: bool,
|
||||||
}
|
}
|
||||||
@ -50,6 +51,7 @@ impl Table {
|
|||||||
pub fn new(name: impl Into<String>) -> Table {
|
pub fn new(name: impl Into<String>) -> Table {
|
||||||
Table {
|
Table {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
|
primary_key: vec![],
|
||||||
columns: vec![],
|
columns: vec![],
|
||||||
has_is_new: false,
|
has_is_new: false,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user