Skip to content
Snippets Groups Projects
Commit afad6c95 authored by Victor Mocelin's avatar Victor Mocelin
Browse files

Adicionado opção unique na tabela people_events

Não adiciona a mesma pessoa duas vezes num mesmo evento.
parent ffddf169
No related branches found
No related tags found
No related merge requests found
...@@ -19,10 +19,10 @@ angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services', ...@@ -19,10 +19,10 @@ angular.module('app', ['ionic', 'app.controllers', 'app.routes', 'app.services',
StatusBar.styleDefault(); StatusBar.styleDefault();
} }
// se o banco não existe, cria ele aqui
var db = $cordovaSQLite.openDB({name: 'ceitificator.db', iosDatabaseLocation: 'default'}); 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 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 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))");
}); });
}) })
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment