Skip to content
Browse files

Added some scripts help with managin the app's database.

make-db.sh - Create a database with some data in it.
pull-db.sh - Pull the app's database from a device.
push-db.sh - Push the database to a device.
  • Loading branch information...
1 parent c5d44c8 commit da3f97502b79a70c86506013e5f72640882276a3 @brasse committed
Showing with 62 additions and 0 deletions.
  1. +44 −0 scripts/make-db.sh
  2. +9 −0 scripts/pull-db.sh
  3. +9 −0 scripts/push-db.sh
View
44 scripts/make-db.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+if [ -z $1 ]; then
+ DB_FILE=notes.db
+else
+ DB_FILE=$1
+fi
+
+if [ -e $DB_FILE ]; then
+ echo "$DB_FILE already exists."
+ exit 1
+fi
+
+sqlite3 $DB_FILE <<EOF
+CREATE TABLE android_metadata (locale TEXT);
+insert into android_metadata values('en_US');
+
+CREATE TABLE notes (_id integer primary key autoincrement,
+ key text,
+ content text not null,
+ modifydate text,
+ createdate text,
+ syncnum integer,
+ version integer,
+ minversion integer,
+ sharekey text,
+ publishkey text,
+ deleted integer not null default 0,
+ pinned integer not null default 0,
+ unread integer not null default 0);
+CREATE TABLE tags (_id integer primary key autoincrement,
+ name text not null,
+ pos integer not null,
+ noteid integer not null,
+ foreign key(noteid) references notes (_id));
+
+insert into notes (_id, content) values(0, 'Take me to your leader! [having quickly written a book to trap the Big Brain in] There, now he''s trapped in a book I wrote: a crummy world of plot holes and spelling errors! You know the worst thing about being a slave? They make you work, but they don''t pay you or let you go. Yeah, and if you were the pope they''d be all, "Straighten your pope hat." And "Put on your good vestments." That''s right, baby. I ain''t your loverboy Flexo, the guy you love so much. You even love anyone pretending to be him!');
+insert into tags values(0, 'long', 0, 0);
+
+insert into notes (_id, content) values(1, 'This is a short note.');
+insert into tags values(1, 'short', 0, 1);
+
+pragma user_version = 1;
+EOF
View
9 scripts/pull-db.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if [ -z $1 ]; then
+ DB_FILE=notes.db
+else
+ DB_FILE=$1
+fi
+
+adb pull /data/data/com.github.simplenotes/databases/$DB_FILE
View
9 scripts/push-db.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+if [ -z $1 ]; then
+ DB_FILE=notes.db
+else
+ DB_FILE=$1
+fi
+
+adb push $DB_FILE /data/data/com.github.simplenotes/databases

0 comments on commit da3f975

Please sign in to comment.
Something went wrong with that request. Please try again.