From 8981efbd2ae867771be5b25c3a29915d3f6624eb Mon Sep 17 00:00:00 2001 From: jekkos-t520 Date: Thu, 26 Feb 2015 22:06:33 +0100 Subject: [PATCH] Fix error in database script Add script to reset database easily (with root user) Remove old git-svn script --- .gitignore | 3 +- database/database.sql | 4 +-- database/resetdatabase.sh | 5 ++++ git-svn-diff.sh | 60 --------------------------------------- 4 files changed, 8 insertions(+), 64 deletions(-) create mode 100755 database/resetdatabase.sh delete mode 100755 git-svn-diff.sh diff --git a/.gitignore b/.gitignore index d05f617d7..ef08cce40 100644 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,7 @@ application/config/database.php patches/ git-svn-diff.py *.bash -*.sh -*.swp +.swp .buildpath .project .settings/* diff --git a/database/database.sql b/database/database.sql index b6bd9dff7..99dde254e 100644 --- a/database/database.sql +++ b/database/database.sql @@ -119,12 +119,12 @@ INSERT INTO `ospos_employees` (`username`, `password`, `person_id`, `deleted`) V CREATE TABLE `ospos_giftcards` ( `record_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `giftcard_id` int(11) NOT NULL AUTO_INCREMENT, - `giftcard_number` varchar(25) dcg utf8_unicode_ci NOT NULL, + `giftcard_number` varchar(25) NOT NULL, `value` decimal(15,2) NOT NULL, `deleted` int(1) NOT NULL DEFAULT '0', `person_id` INT NOT NULL, PRIMARY KEY (`giftcard_id`), - UNIQUE KEY `giftcard_number` (`giftcard_number` + UNIQUE KEY `giftcard_number` (`giftcard_number`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/database/resetdatabase.sh b/database/resetdatabase.sh new file mode 100755 index 000000000..d773360b9 --- /dev/null +++ b/database/resetdatabase.sh @@ -0,0 +1,5 @@ +#!/bin/bash +read -s -p "Enter Password: " mypassword +mysql -u root -p"$mypassword" -e "use ospos; drop database ospos; create database ospos;" +[ ! -z $1 ] && script=migrate_phppos || script=database +mysql -u root -p"$mypassword" -e "use ospos; source $script.sql;" diff --git a/git-svn-diff.sh b/git-svn-diff.sh deleted file mode 100755 index 207fbd354..000000000 --- a/git-svn-diff.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html) -# modified by mike@mikepearce.net -# modified by aconway@[redacted] - handle diffs that introduce new files -# modified by t.broyer@ltgt.net - fixes diffs that introduce new files -# modified by m@rkj.me - fix sed syntax issue in OS X -# modified by rage-shadowman - cleaned up finding of SVN info and handling of path parameters -# modified by tianyapiaozi - cleaned up some diff context lines -# -# Generate an SVN-compatible diff against the tip of the tracking branch - -# Usage: git-svn-diff.sh FROM TO -# or: git-svn-diff.sh TO -# or: git-svn-diff.sh -# -# Gets the SVN diff from the latest dcommitted version of FROM to the latest version of TO - -usage_exit () -{ -echo -echo "Gets the SVN compatible diff from the latest dcommitted version of FROM to the latest version of TO" -echo -echo "Usage: $0 FROM TO" -echo " or: $0 TO" -echo " or: $0" -echo -echo "If FROM is not supplied we will use the latest dcommitted version of HEAD" -echo -echo "If TO is not supplied we will use the latest (possibly non-committed) version of HEAD" -echo -exit 1; -} - -FROM=${2:+$1} -TO=${2:-$1} - -# make sure FROM and TO exist or were not specified -if ! git show-branch $FROM >/dev/null 2>&1 -then -usage_exit -fi - -if ! git show-branch $TO >/dev/null 2>&1 -then -usage_exit -fi - -LATEST_DCOMMIT_HASH=`git log $FROM --grep=^git-svn-id: --first-parent -1 --pretty=format:'%H'` -SVN_REV=`git svn find-rev $LATEST_DCOMMIT_HASH` - -# do the diff and masssage into SVN format -git diff --no-prefix $LATEST_DCOMMIT_HASH $TO | -sed -e "/--- \/dev\/null/{ N; s|^--- /dev/null\n+++ \(.*\)|--- \1 (revision 0)\n+++ \1 (working copy)|;}" \ --e "s/^--- .*/& (revision $SVN_REV)/" \ --e "s/^+++ .*/& (working copy)/" \ --e "s/^\(@@.*@@\).*/\1/" \ --e "s/^diff --git [^[:space:]]*/Index:/" \ --e "s/^index.*/===================================================================/" \ --e "/^new file mode [0-9]\+$/d"