From afad6c95df520aa6ba944495fcd3870ed6d680d3 Mon Sep 17 00:00:00 2001 From: Victor Mocelin <vm13@inf.ufpr.br> Date: Sat, 2 Apr 2016 16:23:06 -0300 Subject: [PATCH] =?UTF-8?q?Adicionado=20op=C3=A7=C3=A3o=20unique=20na=20ta?= =?UTF-8?q?bela=20people=5Fevents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Não adiciona a mesma pessoa duas vezes num mesmo evento. --- www/js/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index eb38402..f5655f3 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -19,10 +19,10 @@ angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', StatusBar.styleDefault(); } + // se o banco não existe, cria ele aqui var db = $cordovaSQLite.openDB({name: 'ceitificator.db', iosDatabaseLocation: 'default'}); $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, grr TEXT NOT NULL, email TEXT NOT NULL, UNIQUE (name, grr, email))"); $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS events(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, desc TEXT NOT NULL, date TEXT NOT NULL, place TEXT NOT NULL, hours TEXT NOT NULL, UNIQUE (name, desc, date, place, hours))"); - $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people_events(event_id, person_id, FOREIGN KEY(event_id) REFERENCES events(id), FOREIGN KEY(person_id) REFERENCES people(id))"); - + $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS people_events(event_id, person_id, FOREIGN KEY(event_id) REFERENCES events(id), FOREIGN KEY(person_id) REFERENCES people(id), UNIQUE (person_id, event_id))"); }); }) -- GitLab