Advertisement
Guest User

kaamoss

a guest
Sep 26th, 2014
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE IF NOT EXISTS `lsnap`.`account` (
  2.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  3.   `first_name` VARCHAR(255) NOT NULL,
  4.   `last_name` VARCHAR(255) NOT NULL,
  5.   `email_address` VARCHAR(255) NOT NULL,
  6.   `avatar_url` VARCHAR(255) NULL,
  7.   `last_login_at` DATETIME NULL,
  8.   `is_locked` TINYINT(1) NOT NULL DEFAULT FALSE,
  9.   `created_at` DATETIME NOT NULL,
  10.   PRIMARY KEY (`id`))
  11. ENGINE = InnoDB;
  12.  
  13. CREATE UNIQUE INDEX `email_address_UNIQUE` ON `lsnap`.`account` (`email_address` ASC);
  14.  
  15.  
  16. -- -----------------------------------------------------
  17. -- Table `lsnap`.`application`
  18. -- -----------------------------------------------------
  19. CREATE TABLE IF NOT EXISTS `lsnap`.`application` (
  20.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  21.   `service` ENUM('Flickr','Facebook','FlickrAuth') NOT NULL,
  22.   `service_provider` ENUM('Flickr','Facebook') NOT NULL,
  23.   `type` ENUM('photo','auth') NOT NULL,
  24.   `key` VARCHAR(255) NOT NULL,
  25.   `secret` VARCHAR(255) NOT NULL,
  26.   `created_at` DATETIME NOT NULL,
  27.   PRIMARY KEY (`id`))
  28. ENGINE = InnoDB
  29. COMMENT = '1. Flickr is primary service provider.';
  30.  
  31.  
  32. -- -----------------------------------------------------
  33. -- Table `lsnap`.`account_application`
  34. -- -----------------------------------------------------
  35. CREATE TABLE IF NOT EXISTS `lsnap`.`account_application` (
  36.   `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
  37.   `application_id` INT UNSIGNED NOT NULL,
  38.   `account_id` INT UNSIGNED NOT NULL,
  39.   `label` VARCHAR(255) NOT NULL,
  40.   `token` VARCHAR(255) NOT NULL,
  41.   `secret` VARCHAR(255) NULL,
  42.   `created_at` DATETIME NOT NULL,
  43.   PRIMARY KEY (`id`),
  44.   CONSTRAINT `fk_user_application_application`
  45.     FOREIGN KEY (`application_id`)
  46.     REFERENCES `lsnap`.`application` (`id`)
  47.     ON DELETE CASCADE
  48.     ON UPDATE NO ACTION)
  49. ENGINE = InnoDB;
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. /**
  65. * Account.js
  66. *
  67. * @description :: This represents a user account in our account table
  68. * @docs        :: http://sailsjs.org/#!documentation/models
  69. */
  70.  
  71. module.exports = {
  72.  
  73.   attributes: {
  74.     id: {
  75.       type: 'integer',
  76.       autoIncrement: true,
  77.       primaryKey: true,
  78.       unique: true
  79.     },
  80.     firstName: {
  81.       type: 'string',
  82.       required: true,
  83.       columnName: 'first_name'
  84.     },
  85.     lastName: {
  86.       type: 'string',
  87.       required: true,
  88.       columnName: 'last_name'
  89.     },
  90.     emailAddress: {
  91.       type: 'string',
  92.       unique: true,
  93.       required: true,
  94.       columnName: 'email_address'
  95.     },
  96.     avatarUrl: {
  97.       type: 'string',
  98.       columnName: 'avatar_url'
  99.     },
  100.     lastLoginAt: {
  101.       type: 'datetime',
  102.       columnName: 'last_login_at'
  103.     },
  104.     isLocked: {
  105.       type: 'boolean',
  106.       defaultsTo: false,
  107.       columnName: 'is_locked'
  108.     },
  109.     createdAt: {
  110.       type: 'datetime',
  111.       required: true,
  112.       columnName: 'created_at',
  113.       defaultsTo: function (){ return new Date(); }
  114.     },
  115.     applications: {
  116.       collection: 'accountapplication',
  117.       via: 'account'
  118.     }
  119.   }
  120. };'
  121.  
  122.  
  123.  
  124. /**
  125. * Account_application.js
  126. *
  127. * @description :: TODO: You might write a short summary of how this model works and what it represents here.
  128. * @docs        :: http://sailsjs.org/#!documentation/models
  129. */
  130.  
  131. module.exports = {
  132.  tableName: 'account_application',
  133.  attributes: {
  134.    id: {
  135.      type: 'integer',
  136.      autoIncrement: true,
  137.      primaryKey: true,
  138.      unique: true
  139.    },
  140.    accountId: {
  141.      type: 'integer',
  142.      required: true,
  143.      columnName: 'account_id'
  144.    },
  145.    applicationId: {
  146.      type: 'integer',
  147.      required: true,
  148.      columnName: 'application_id'
  149.    },
  150.    label: {
  151.      type: 'string',
  152.      required: true
  153.    },
  154.    token: {
  155.      type: 'string',
  156.      required: true
  157.    },
  158.    secret: {
  159.      type: 'string'
  160.    },
  161.    createdAt: {
  162.      type: 'datetime',
  163.      required: true,
  164.      columnName: 'created_at',
  165.      defaultsTo: function (){ return new Date(); }
  166.    },
  167.    account: {
  168.      model: 'account'
  169.    },
  170.    application: {
  171.      model: 'application'
  172.    }
  173.  }
  174. };
  175.  
  176.  
  177.  
  178. /**
  179. * Application.js
  180. *
  181. * @description :: TODO: You might write a short summary of how this model works and what it represents here.
  182. * @docs        :: http://sailsjs.org/#!documentation/models
  183. */
  184.  
  185. module.exports = {
  186.  
  187.  attributes: {
  188.    id: {
  189.      type: 'integer',
  190.      autoIncrement: true,
  191.      primaryKey: true,
  192.      unique: true
  193.    },
  194.    service: {
  195.      type: 'string',
  196.      enum: ['Flickr','Facebook','FlickrAuth'],
  197.      required: true
  198.    },
  199.    serviceProvider: {
  200.      type: 'string',
  201.      enum: ['Flickr','Facebook'],
  202.      required: true,
  203.      columnName: 'service_provider'
  204.    },
  205.    type: {
  206.      type: 'string',
  207.      enum: ['auth','photo'],
  208.      required: true
  209.    },
  210.    key: {
  211.      type: 'string',
  212.      required: true
  213.    },
  214.    secret: {
  215.      type: 'string',
  216.      required: true
  217.    },
  218.    createdAt: {
  219.      type: 'datetime',
  220.      required: true,
  221.      columnName: 'created_at',
  222.      defaultsTo: function (){ return new Date(); }
  223.    },
  224.    applications: {
  225.      model: 'accountapplication'
  226.    }
  227.  }
  228. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement