package com.example.android.waitlist.data;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

// completed (1) extend the SQLiteOpenHelper class
public class WaitlistDbHelper extends SQLiteOpenHelper{

    // completed (2) Create a static final String called DATABASE_NAME and set it to "waitlist.db"
    public static final String DATABASE_NAME = "waitlist.db";

    // completed (3) Create a static final int called DATABASE_VERSION and set it to 1
    public static final int DATABASE_VERSION = 1;

    // completed (4) Create a Constructor that takes a context and calls the parent constructor
    public WaitlistDbHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    // completed (5) Override the onCreate method
    @Override
    public void onCreate(SQLiteDatabase db) {

        // TODO (6) Inside, create an String query called SQL_CREATE_WAITLIST_TABLE that will create the table

        // TODO (7) Execute the query by calling execSQL on sqLiteDatabase and pass the string query SQL_CREATE_WAITLIST_TABLE

    }

    // completed (8) Override the onUpgrade method
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        // TODO (9) Inside, execute a drop table query, and then call onCreate to re-create it


    }

}
@@ -374,29 +374,30 @@
 st.db%22%0A    p
-ublic
+rivate
  static fina
@@ -529,21 +529,22 @@
  1%0A    p
-ublic
+rivate
  static 
@@ -719,121 +719,72 @@
 text
-, String name, SQLiteDatabase.CursorFactory factory, int version) %7B%0A        super(context, name, factory, version
+) %7B%0A        super(context, DATABASE_NAME, null, DATABASE_VERSION
 );%0A 
@@ -911,20 +911,25 @@
      // 
-TODO
+COMPLETED
  (6) Ins
@@ -1016,32 +1016,572 @@
 e table%0A
-%0A        // TODO
+        final String SQL_CREATE_WAITLIST_TABLE = %22CREATE TABLE %22 +%0A                WaitlistContract.WaitlistEntry.TABLE_NAME + %22 (%22 +%0A                WaitlistContract.WaitlistEntry._ID + %22 INTEGER PRIMARY KEY AUTOINCREMENT,%22 +%0A                WaitlistContract.WaitlistEntry.COLUMN_GUEST_NAME + %22 TEXT NOT NULL, %22 +%0A                WaitlistContract.WaitlistEntry.COLUMN_PARTY_SIZE + %22 INTEGER NOT NULL%22 +%0A                WaitlistContract.WaitlistEntry.COLUMN_TIMESTAMP + %22 TIMESTAMP DEFAULT CURRENT_TIMESTAMP%22 +%0A                %22);%22;%0A%0A%0A%0A        // completed
  (7) Exe
@@ -1684,16 +1684,62 @@
 T_TABLE%0A
+        db.execSQL(SQL_CREATE_WAITLIST_TABLE);
 %0A    %7D%0A%0A
@@ -1898,12 +1898,17 @@
  // 
-TODO
+completed
  (9)
@@ -1983,16 +1983,128 @@
 eate it%0A
+        db.execSQL(%22DROP TABLE IF EXISTS %22 + WaitlistContract.WaitlistEntry.TABLE_NAME);%0A        onCreate((db));
 %0A%0A    %7D%0A

complete OnCreate() by adding SQL query