From 0b7471467e699fa2f29442f74ca2bb50fdb74ee2 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 9 Jul 2019 12:15:03 +0200 Subject: [PATCH] Switch FLOAT types to DOUBLE in the database SQLite has no NUMERIC(8,3) type, which it should acutally be. Switch to DOUBLE, because FLOAT maps to f32 which is not supported by GraphQL. --- .../2019-06-08-190258_create_customers/up.sql | 2 +- migrations/2019-06-08-190852_create_tasks/up.sql | 6 +++--- src/models/customer.rs | 4 ++-- src/models/task.rs | 12 ++++++------ src/schema.rs | 16 ++++++++-------- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/migrations/2019-06-08-190258_create_customers/up.sql b/migrations/2019-06-08-190258_create_customers/up.sql index 0741302..68745b5 100644 --- a/migrations/2019-06-08-190258_create_customers/up.sql +++ b/migrations/2019-06-08-190258_create_customers/up.sql @@ -5,7 +5,7 @@ CREATE TABLE customers ( "address_street" VARCHAR(255) NOT NULL, "email" VARCHAR(255) NOT NULL, "financial_contact" VARCHAR(255) NOT NULL, - "hourly_rate" FLOAT, + "hourly_rate" DOUBLE, "name" VARCHAR(255) NOT NULL, "phone" VARCHAR(255) NOT NULL, "short_name" VARCHAR(255) NOT NULL, diff --git a/migrations/2019-06-08-190852_create_tasks/up.sql b/migrations/2019-06-08-190852_create_tasks/up.sql index 5f7f4fe..2120cf2 100644 --- a/migrations/2019-06-08-190852_create_tasks/up.sql +++ b/migrations/2019-06-08-190852_create_tasks/up.sql @@ -1,12 +1,12 @@ CREATE TABLE tasks ( "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "customer_id" INTEGER NOT NULL, - "fixed_cost" FLOAT, - "hourly_rate" FLOAT, + "fixed_cost" DOUBLE, + "hourly_rate" DOUBLE, "invoice_comment" VARCHAR(255) NOT NULL, "invoice_id" INTEGER, "name" VARCHAR(255) NOT NULL, - "vat_rate" FLOAT NOT NULL, + "vat_rate" DOUBLE NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ) diff --git a/src/models/customer.rs b/src/models/customer.rs index 1024f93..eaa0fd2 100644 --- a/src/models/customer.rs +++ b/src/models/customer.rs @@ -23,7 +23,7 @@ pub struct Customer { /// The name of the financial contact person/department pub financial_contact: String, /// The default hourly rate (if applicable) - pub hourly_rate: Option, + pub hourly_rate: Option, /// The official (long) name pub name: String, /// The phone number @@ -55,7 +55,7 @@ pub struct NewCustomer { /// The name of the financial contact person/department pub financial_contact: String, /// The default hourly rate (if applicable) - pub hourly_rate: Option, + pub hourly_rate: Option, /// The official (long) name pub name: String, /// The phone number diff --git a/src/models/task.rs b/src/models/task.rs index 1c1f35e..487c339 100644 --- a/src/models/task.rs +++ b/src/models/task.rs @@ -18,9 +18,9 @@ pub struct Task { /// The ID of the associated customer pub customer_id: i32, /// The fixed cost of the task (if applicable) - pub fixed_cost: Option, + pub fixed_cost: Option, /// The hourly rate of the task (if applicable) - pub hourly_rate: Option, + pub hourly_rate: Option, /// An extra comment for on the invoice pub invoice_comment: String, /// The associated invoice (if billed) @@ -28,7 +28,7 @@ pub struct Task { /// The name/description pub name: String, /// The VAT rate (at time of billing) - pub vat_rate: f32, + pub vat_rate: f64, /// The time of creation pub created_at: NaiveDateTime, /// The time of last update @@ -45,9 +45,9 @@ pub struct NewTask { /// The ID of the associated customer pub customer_id: i32, /// The fixed cost of the task (if applicable) - pub fixed_cost: Option, + pub fixed_cost: Option, /// The hourly rate of the task (if applicable) - pub hourly_rate: Option, + pub hourly_rate: Option, /// An extra comment for on the invoice pub invoice_comment: String, /// The associated invoice (if billed) @@ -55,5 +55,5 @@ pub struct NewTask { /// The name/description pub name: String, /// The VAT rate (at time of billing) - pub vat_rate: f32, + pub vat_rate: f64, } diff --git a/src/schema.rs b/src/schema.rs index d1f38a8..ec9d168 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -181,10 +181,10 @@ table! { financial_contact -> Text, /// The `hourly_rate` column of the `customers` table. /// - /// Its SQL type is `Nullable`. + /// Its SQL type is `Nullable`. /// /// (Automatically generated by Diesel.) - hourly_rate -> Nullable, + hourly_rate -> Nullable, /// The `name` column of the `customers` table. /// /// Its SQL type is `Text`. @@ -299,16 +299,16 @@ table! { customer_id -> Integer, /// The `fixed_cost` column of the `tasks` table. /// - /// Its SQL type is `Nullable`. + /// Its SQL type is `Nullable`. /// /// (Automatically generated by Diesel.) - fixed_cost -> Nullable, + fixed_cost -> Nullable, /// The `hourly_rate` column of the `tasks` table. /// - /// Its SQL type is `Nullable`. + /// Its SQL type is `Nullable`. /// /// (Automatically generated by Diesel.) - hourly_rate -> Nullable, + hourly_rate -> Nullable, /// The `invoice_comment` column of the `tasks` table. /// /// Its SQL type is `Text`. @@ -329,10 +329,10 @@ table! { name -> Text, /// The `vat_rate` column of the `tasks` table. /// - /// Its SQL type is `Float`. + /// Its SQL type is `Double`. /// /// (Automatically generated by Diesel.) - vat_rate -> Float, + vat_rate -> Double, /// The `created_at` column of the `tasks` table. /// /// Its SQL type is `Timestamp`.