From fd211e7de2aa3638bd5e7cfcfd6f0324103155e7 Mon Sep 17 00:00:00 2001 From: Dave Shoreman Date: Sat, 11 Oct 2014 14:30:02 +0100 Subject: [PATCH] Remove addresses table, keep everything in orders After spending all that time sorting the addresses stuff, I noticed there'd be an issue creating the orders. Rather than faff about making the database happy with no address relations, we'll just ditch them. No reason they can't live with orders anyway. --- models/Address.php | 39 ------------------------------ models/address/columns.yaml | 29 ---------------------- models/address/fields.yaml | 20 --------------- updates/create_addresses_table.php | 30 ----------------------- updates/create_orders_table.php | 17 ++++++++----- updates/version.yaml | 1 - 6 files changed, 11 insertions(+), 125 deletions(-) delete mode 100644 models/Address.php delete mode 100644 models/address/columns.yaml delete mode 100644 models/address/fields.yaml delete mode 100644 updates/create_addresses_table.php diff --git a/models/Address.php b/models/Address.php deleted file mode 100644 index 3780caf..0000000 --- a/models/Address.php +++ /dev/null @@ -1,39 +0,0 @@ -engine = 'InnoDB'; - $table->increments('id'); - $table->string('name'); - $table->string('street'); - $table->string('town'); - $table->string('county'); - $table->string('postcode'); - $table->string('country'); - $table->timestamps(); - }); - } - - public function down() - { - Schema::dropIfExists('dshoreman_shop_addresses'); - } - -} diff --git a/updates/create_orders_table.php b/updates/create_orders_table.php index 2d2e01d..213b31d 100644 --- a/updates/create_orders_table.php +++ b/updates/create_orders_table.php @@ -13,16 +13,21 @@ public function up() $table->engine = 'InnoDB'; $table->increments('id'); $table->string('email'); - $table->string('stripe_token'); - $table->integer('billing_address')->unsigned(); - $table->integer('shipping_address')->unsigned(); $table->text('items'); $table->decimal('total', 7, 2); $table->boolean('is_paid')->default(false); + $table->string('stripe_token'); + $table->string('billing_name'); + $table->string('billing_street'); + $table->string('billing_town'); + $table->string('billing_county'); + $table->string('billing_postcode'); + $table->string('shipping_name'); + $table->string('shipping_street'); + $table->string('shipping_town'); + $table->string('shipping_county'); + $table->string('shipping_postcode'); $table->timestamps(); - - $table->foreign('billing_address')->references('id')->on('dshoreman_shop_addresses'); - $table->foreign('shipping_address')->references('id')->on('dshoreman_shop_addresses'); }); } diff --git a/updates/version.yaml b/updates/version.yaml index d931719..786a37a 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -2,6 +2,5 @@ - First version of Shop - create_categories_table.php - create_products_table.php - - create_addresses_table.php - create_orders_table.php - demo_seed.php