From a86f6a2cef1400a6ba290695cdcc36e59ff58438 Mon Sep 17 00:00:00 2001
From: ryanorsinger
Date: Mon, 20 Apr 2015 14:37:44 -0500
Subject: [PATCH 1/5] Add migrations and simplify requires to bootstrap
---
adlister_login.php | 6 ----
bootstrap.php | 26 ++++++++++++++++
database/create_items_table_migration.php | 16 ++++++++++
database/create_users_table_migration.php | 13 ++++++++
database/migration.php | 6 ++++
models/BaseModel.php | 10 +++----
public/{ad.create.php => ads.create.php} | 3 +-
public/{ad.index.php => ads.index.php} | 0
public/index.php | 36 +++++++++++++++++++++--
utils/Auth.php | 3 ++
utils/Input.php | 2 +-
utils/Logger.php | 3 ++
12 files changed, 108 insertions(+), 16 deletions(-)
delete mode 100644 adlister_login.php
create mode 100644 database/create_items_table_migration.php
create mode 100644 database/create_users_table_migration.php
rename public/{ad.create.php => ads.create.php} (83%)
rename public/{ad.index.php => ads.index.php} (100%)
diff --git a/adlister_login.php b/adlister_login.php
deleted file mode 100644
index 973af47..0000000
--- a/adlister_login.php
+++ /dev/null
@@ -1,6 +0,0 @@
-setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
diff --git a/database/create_items_table_migration.php b/database/create_items_table_migration.php
new file mode 100644
index 0000000..12ba7fb
--- /dev/null
+++ b/database/create_items_table_migration.php
@@ -0,0 +1,16 @@
+exec('DROP TABLE IF EXISTS items');
+
+$query = 'CREATE TABLE items (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ price INT UNSIGNED NOT NULL,
+ item VARCHAR(256) NOT NULL,
+ description TEXT,
+ location VARCHAR(256),
+ date_posted DATE,
+ user_id INT UNSIGNED,
+ PRIMARY KEY (id)
+)';
+
+$dbc->exec($query);
diff --git a/database/create_users_table_migration.php b/database/create_users_table_migration.php
new file mode 100644
index 0000000..e3409d0
--- /dev/null
+++ b/database/create_users_table_migration.php
@@ -0,0 +1,13 @@
+exec('DROP TABLE IF EXISTS users');
+
+$query = 'CREATE TABLE users (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ email VARCHAR(128) NOT NULL,
+ password VARCHAR(256) NOT NULL,
+ PRIMARY KEY (id)
+)';
+
+$dbc->exec($query);
diff --git a/database/migration.php b/database/migration.php
index e69de29..aec9c96 100644
--- a/database/migration.php
+++ b/database/migration.php
@@ -0,0 +1,6 @@
+
-
-
+
- Welcome to Chadlister!
+
+
+
+ Welcome to Radlister!
+ The rad way to post free, unlimited ads!
+
+
diff --git a/public/ad.index.php b/public/ads.index.php
similarity index 100%
rename from public/ad.index.php
rename to public/ads.index.php
diff --git a/public/index.php b/public/index.php
index ecdd5e0..692311e 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,14 +1,46 @@