#!/usr/bin/env ruby -w
require "sqlite3"

# Create new tables
rows = db.execute <<-SQL
  CREATE TABLE user (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    email varchar(64)
  );
SQL

rows = db.execute <<-SQL
  CREATE TABLE processor (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name varchar(32),
    type varchar(16)
  );
SQL

rows = db.execute <<-SQL
  CREATE TABLE pmt_interval (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    type varchar(8),
    cents int
  );
SQL

rows = db.execute <<-SQL
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id int,
    processor_id int,
    pmt_interval_id int,
    lastPayment int,
    expiration int,
    json_processor_data BLOB
  ); 
SQL

#!/usr/bin/env ruby -w
require "sqlite3"

# Open a database
db = SQLite3::Database.new "sqlite3.db"

# Drop old tables
rows = db.execute <<-SQL
  DROP TABLE IF EXISTS user;
SQL

rows = db.execute <<-SQL
  DROP TABLE IF EXISTS processor;
SQL

rows = db.execute <<-SQL
  DROP TABLE IF EXISTS pmt_interval;
SQL

rows = db.execute <<-SQL
  DROP TABLE IF EXISTS subscription;
SQL


# Create new tables
rows = db.execute <<-SQL
  CREATE TABLE user (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    email varchar(64)
  );
SQL

rows = db.execute <<-SQL
  CREATE TABLE processor (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name varchar(32),
    type varchar(16)
  );
SQL

rows = db.execute <<-SQL
  CREATE TABLE pmt_interval (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    type varchar(8),
    cents int
  );
SQL

rows = db.execute <<-SQL
  CREATE TABLE subscription (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id int,
    processor_id int,
    pmt_interval_id int,
    lastPayment int,
    expiration int,
    json_processor_data BLOB
  ); 
SQL

Drop old tables for multiple executions
Drop old tables for multiple executions

Drop old data, each run makes a new DB.
