Actually use Diesel schema macros

This commit is contained in:
Timothy Warren 2019-04-05 19:06:43 -04:00
parent 7c67b11017
commit 97a3704472
5 changed files with 9 additions and 13 deletions

View File

@ -6,7 +6,6 @@ CREATE TABLE IF NOT EXISTS public.media_type (
CONSTRAINT media_type_pkey PRIMARY KEY (id) CONSTRAINT media_type_pkey PRIMARY KEY (id)
); );
CREATE TABLE IF NOT EXISTS public.media_format ( CREATE TABLE IF NOT EXISTS public.media_format (
id serial NOT NULL, id serial NOT NULL,
is_physical boolean NOT NULL DEFAULT false, is_physical boolean NOT NULL DEFAULT false,

View File

@ -1,13 +1,10 @@
use handlebars_iron::handlebars::to_json; use handlebars_iron::handlebars::to_json;
use handlebars_iron::Template; use handlebars_iron::Template;
use iron::prelude::{Request, Response}; use iron::prelude::{Request, Response};
use iron::{IronResult, Set, status}; use iron::{IronResult, Set, status};
use mount::Mount; use mount::Mount;
use serde::ser::Serialize as ToJson;
use serde_json::value::{Map, Value}; use serde_json::value::{Map, Value};
use staticfile::Static; use staticfile::Static;
use std::error::Error;
use std::path::Path; use std::path::Path;
pub fn render_page(name: &str, mut template_data: Map<String, Value>) -> Template { pub fn render_page(name: &str, mut template_data: Map<String, Value>) -> Template {
@ -37,4 +34,4 @@ pub fn hello_world (_request: &mut Request) -> IronResult<Response> {
.set_mut(status::Ok); .set_mut(status::Ok);
Ok(response) Ok(response)
} }

View File

@ -1,6 +1,11 @@
#[macro_use]
extern crate diesel;
pub mod chain; pub mod chain;
pub mod db; pub mod db;
pub mod handlers; pub mod handlers;
pub mod models; pub mod models;
// pub mod schema;
#[macro_use]
pub mod schema;

View File

@ -1,9 +1,8 @@
use diesel::Queryable; use diesel::Queryable;
// use crate::schema::*; use crate::schema::*;
#[derive(Debug, Queryable)] #[derive(Debug, Queryable)]
// #[table_name="media"]
pub struct Media { pub struct Media {
pub id: u32, pub id: u32,
pub display_name: String, pub display_name: String,
@ -11,7 +10,6 @@ pub struct Media {
} }
#[derive(Debug, Queryable)] #[derive(Debug, Queryable)]
// #[table_name="media_type"]
pub struct MediaType { pub struct MediaType {
pub id: u32, pub id: u32,
pub type_name: String, pub type_name: String,
@ -19,7 +17,6 @@ pub struct MediaType {
} }
#[derive(Debug, Queryable)] #[derive(Debug, Queryable)]
// #[table_name="media_format"]
pub struct MediaFormat { pub struct MediaFormat {
pub id: u32, pub id: u32,
pub is_physical: bool, pub is_physical: bool,
@ -31,4 +28,4 @@ pub struct MediaFormat {
pub struct MediaTypeFormatLink { pub struct MediaTypeFormatLink {
pub media_type_id: i32, pub media_type_id: i32,
pub media_format_id: i32, pub media_format_id: i32,
} }

View File

@ -1,5 +1,3 @@
use diesel::macros::*;
table! { table! {
/// Representation of the `media_format` table. /// Representation of the `media_format` table.
/// ///