Alex Mikhalev
4 years ago
5 changed files with 26 additions and 21 deletions
@ -1,27 +1,18 @@
@@ -1,27 +1,18 @@
|
||||
use crate::migrations::{Migrations, SimpleMigration}; |
||||
|
||||
macro_rules! include_file_migration { |
||||
($mig_version:expr, $mig_name:literal) => { |
||||
SimpleMigration::new_box( |
||||
$mig_version, |
||||
include_str!(concat!("migrations/", $mig_name, "-up.sql")), |
||||
include_str!(concat!("migrations/", $mig_name, "-down.sql")), |
||||
) |
||||
}; |
||||
} |
||||
|
||||
pub fn create_migrations() -> Migrations { |
||||
let mut migs = Migrations::new(); |
||||
migs.add(SimpleMigration::new_box( |
||||
1, |
||||
"CREATE TABLE sections ( |
||||
id INTEGER PRIMARY KEY, |
||||
name TEXT NOT NULL, |
||||
interface_id INTEGER NOT NULL |
||||
);", |
||||
"DROP TABLE sections;", |
||||
)); |
||||
migs.add(SimpleMigration::new_box( |
||||
2, |
||||
"INSERT INTO sections (id, name, interface_id) |
||||
VALUES
|
||||
(1, 'Front Yard Middle', 0), |
||||
(2, 'Front Yard Left', 1), |
||||
(3, 'Front Yard Right', 2), |
||||
(4, 'Back Yard Middle', 3), |
||||
(5, 'Back Yard Sauna', 4), |
||||
(6, 'Garden', 5);", |
||||
"DELETE FROM sections;", |
||||
)); |
||||
migs.add(include_file_migration!(1, "0001-table_sections")); |
||||
migs.add(include_file_migration!(2, "0002-section_rows")); |
||||
migs |
||||
} |
||||
|
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
DROP TABLE sections; |
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE sections ( |
||||
id INTEGER PRIMARY KEY, |
||||
name TEXT NOT NULL, |
||||
interface_id INTEGER NOT NULL |
||||
); |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
DELETE FROM sections; |
@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
|
||||
INSERT INTO sections (id, name, interface_id) |
||||
VALUES (1, 'Front Yard Middle', 0), |
||||
(2, 'Front Yard Left', 1), |
||||
(3, 'Front Yard Right', 2), |
||||
(4, 'Back Yard Middle', 3), |
||||
(5, 'Back Yard Sauna', 4), |
||||
(6, 'Garden', 5); |
Loading…
Reference in new issue