Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE IF NOT EXISTS `lsnap`.`account` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- `first_name` VARCHAR(255) NOT NULL,
- `last_name` VARCHAR(255) NOT NULL,
- `email_address` VARCHAR(255) NOT NULL,
- `avatar_url` VARCHAR(255) NULL,
- `last_login_at` DATETIME NULL,
- `is_locked` TINYINT(1) NOT NULL DEFAULT FALSE,
- `created_at` DATETIME NOT NULL,
- PRIMARY KEY (`id`))
- ENGINE = InnoDB;
- CREATE UNIQUE INDEX `email_address_UNIQUE` ON `lsnap`.`account` (`email_address` ASC);
- -- -----------------------------------------------------
- -- Table `lsnap`.`application`
- -- -----------------------------------------------------
- CREATE TABLE IF NOT EXISTS `lsnap`.`application` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- `service` ENUM('Flickr','Facebook','FlickrAuth') NOT NULL,
- `service_provider` ENUM('Flickr','Facebook') NOT NULL,
- `type` ENUM('photo','auth') NOT NULL,
- `key` VARCHAR(255) NOT NULL,
- `secret` VARCHAR(255) NOT NULL,
- `created_at` DATETIME NOT NULL,
- PRIMARY KEY (`id`))
- ENGINE = InnoDB
- COMMENT = '1. Flickr is primary service provider.';
- -- -----------------------------------------------------
- -- Table `lsnap`.`account_application`
- -- -----------------------------------------------------
- CREATE TABLE IF NOT EXISTS `lsnap`.`account_application` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- `application_id` INT UNSIGNED NOT NULL,
- `account_id` INT UNSIGNED NOT NULL,
- `label` VARCHAR(255) NOT NULL,
- `token` VARCHAR(255) NOT NULL,
- `secret` VARCHAR(255) NULL,
- `created_at` DATETIME NOT NULL,
- PRIMARY KEY (`id`),
- CONSTRAINT `fk_user_application_application`
- FOREIGN KEY (`application_id`)
- REFERENCES `lsnap`.`application` (`id`)
- ON DELETE CASCADE
- ON UPDATE NO ACTION)
- ENGINE = InnoDB;
- /**
- * Account.js
- *
- * @description :: This represents a user account in our account table
- * @docs :: http://sailsjs.org/#!documentation/models
- */
- module.exports = {
- attributes: {
- id: {
- type: 'integer',
- autoIncrement: true,
- primaryKey: true,
- unique: true
- },
- firstName: {
- type: 'string',
- required: true,
- columnName: 'first_name'
- },
- lastName: {
- type: 'string',
- required: true,
- columnName: 'last_name'
- },
- emailAddress: {
- type: 'string',
- unique: true,
- required: true,
- columnName: 'email_address'
- },
- avatarUrl: {
- type: 'string',
- columnName: 'avatar_url'
- },
- lastLoginAt: {
- type: 'datetime',
- columnName: 'last_login_at'
- },
- isLocked: {
- type: 'boolean',
- defaultsTo: false,
- columnName: 'is_locked'
- },
- createdAt: {
- type: 'datetime',
- required: true,
- columnName: 'created_at',
- defaultsTo: function (){ return new Date(); }
- },
- applications: {
- collection: 'accountapplication',
- via: 'account'
- }
- }
- };'
- /**
- * Account_application.js
- *
- * @description :: TODO: You might write a short summary of how this model works and what it represents here.
- * @docs :: http://sailsjs.org/#!documentation/models
- */
- module.exports = {
- tableName: 'account_application',
- attributes: {
- id: {
- type: 'integer',
- autoIncrement: true,
- primaryKey: true,
- unique: true
- },
- accountId: {
- type: 'integer',
- required: true,
- columnName: 'account_id'
- },
- applicationId: {
- type: 'integer',
- required: true,
- columnName: 'application_id'
- },
- label: {
- type: 'string',
- required: true
- },
- token: {
- type: 'string',
- required: true
- },
- secret: {
- type: 'string'
- },
- createdAt: {
- type: 'datetime',
- required: true,
- columnName: 'created_at',
- defaultsTo: function (){ return new Date(); }
- },
- account: {
- model: 'account'
- },
- application: {
- model: 'application'
- }
- }
- };
- /**
- * Application.js
- *
- * @description :: TODO: You might write a short summary of how this model works and what it represents here.
- * @docs :: http://sailsjs.org/#!documentation/models
- */
- module.exports = {
- attributes: {
- id: {
- type: 'integer',
- autoIncrement: true,
- primaryKey: true,
- unique: true
- },
- service: {
- type: 'string',
- enum: ['Flickr','Facebook','FlickrAuth'],
- required: true
- },
- serviceProvider: {
- type: 'string',
- enum: ['Flickr','Facebook'],
- required: true,
- columnName: 'service_provider'
- },
- type: {
- type: 'string',
- enum: ['auth','photo'],
- required: true
- },
- key: {
- type: 'string',
- required: true
- },
- secret: {
- type: 'string',
- required: true
- },
- createdAt: {
- type: 'datetime',
- required: true,
- columnName: 'created_at',
- defaultsTo: function (){ return new Date(); }
- },
- applications: {
- model: 'accountapplication'
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement