Commit d1f67d4e authored by Katharina Fey's avatar Katharina Fey 🏴
Browse files

Adding `CustomLine` change to allow Sql injection into migrations

This makes it possible to work around missing `barrel` features
without hitting a wall.
parent 84979345
......@@ -124,6 +124,9 @@ pub enum TableChange {
/// Remove a column
DropColumn(String),
/// Add some custom SQL
CustomLine(String),
}
/// An enum set that represents a single change on a database
......
......@@ -61,6 +61,10 @@ impl Table {
.push(TableChange::RenameColumn(old.into(), new.into()));
}
pub fn inject_custom<S: Into<String>>(&mut self, sql: S) {
self.changes.push(TableChange::CustomLine(sql.into()));
}
pub fn make<T: SqlGenerator>(&mut self, ex: bool, schema: Option<&str>) -> Vec<String> {
use TableChange::*;
......@@ -71,6 +75,7 @@ impl Table {
&mut DropColumn(ref name) => T::drop_column(name),
&mut RenameColumn(ref old, ref new) => T::rename_column(old, new),
&mut ChangeColumn(ref mut name, _, _) => T::alter_table(name, schema),
&mut CustomLine(ref sql) => sql.clone()
})
.collect()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment