-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt `README.md` Change the migrations scripts Change all the references (functions and structs)
- Loading branch information
Showing
7 changed files
with
62 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/diesel/migrations/2018-01-31-183719_create_posts/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
DROP TABLE posts | ||
DROP TABLE products |
6 changes: 3 additions & 3 deletions
6
examples/diesel/migrations/2018-01-31-183719_create_posts/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
CREATE TABLE posts ( | ||
CREATE TABLE IF NOT EXISTS products ( | ||
id INTEGER PRIMARY KEY, | ||
title VARCHAR NOT NULL, | ||
body TEXT NOT NULL, | ||
published BOOLEAN NOT NULL DEFAULT 'f' | ||
price REAL NOT NULL, | ||
link VARCHAR NOT NULL | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
//! Holds the two possible structs that are `Queryable` and | ||
//! `Insertable` in the DB | ||
|
||
use super::schema::posts; | ||
use super::schema::products; | ||
|
||
/// Represents a post in the DB. | ||
/// Represents a product in the DB. | ||
/// It is `Queryable` | ||
#[derive(Queryable, Serialize, Debug)] | ||
pub struct Post { | ||
pub struct Product { | ||
pub id: Option<i32>, | ||
pub title: String, | ||
pub body: String, | ||
pub published: bool, | ||
pub price: f32, | ||
pub link: String, | ||
} | ||
|
||
/// Represents a new post to insert in the DB. | ||
/// Represents a new product to insert in the DB. | ||
#[derive(Insertable, Deserialize)] | ||
#[table_name = "posts"] | ||
pub struct NewPost<'a> { | ||
#[table_name = "products"] | ||
pub struct NewProduct<'a> { | ||
pub title: &'a str, | ||
pub body: &'a str, | ||
pub published: bool, | ||
pub price: f32, | ||
pub link: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
table! { | ||
posts (id) { | ||
products (id) { | ||
id -> Nullable<Integer>, | ||
title -> Text, | ||
body -> Text, | ||
published -> Bool, | ||
price -> Float, | ||
link -> Text, | ||
} | ||
} |