refactor: cleanup models

pull/4/head
Cameron Clough 2022-03-12 23:26:10 +00:00
parent e8ea76c46a
commit f066ab53f6
No known key found for this signature in database
GPG Key ID: BFB3B74B026ED43F
7 changed files with 200 additions and 184 deletions

View File

@ -1,50 +1,54 @@
import { DataTypes } from 'sequelize';
export default (sequelize) => {
sequelize.define('accounts', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
sequelize.define(
'accounts',
{
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
},
email: {
allowNull: false,
type: DataTypes.TEXT,
},
password: {
allowNull: true,
type: DataTypes.TEXT,
},
created: {
allowNull: true,
type: DataTypes.BIGINT,
},
last_ping: {
allowNull: true,
type: DataTypes.BIGINT,
},
'2fa_token': {
allowNull: true,
type: DataTypes.TEXT,
},
admin: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
email_verify_token: {
allowNull: true,
type: DataTypes.TEXT,
},
g_oauth_sub: {
allowNull: true,
type: DataTypes.TEXT,
},
two_factor_enabled: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
},
email: {
allowNull: false,
type: DataTypes.TEXT,
{
timestamps: false,
},
password: {
allowNull: true,
type: DataTypes.TEXT,
},
created: {
allowNull: true,
type: DataTypes.BIGINT,
},
last_ping: {
allowNull: true,
type: DataTypes.BIGINT,
},
'2fa_token': {
allowNull: true,
type: DataTypes.TEXT,
},
admin: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
email_verify_token: {
allowNull: true,
type: DataTypes.TEXT,
},
g_oauth_sub: {
allowNull: true,
type: DataTypes.TEXT,
},
two_factor_enabled: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
}, {
timestamps: false,
});
);
};

View File

@ -1,46 +1,50 @@
import { DataTypes } from 'sequelize';
export default (sequelize) => {
sequelize.define('athena_action_log', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
sequelize.define(
'athena_action_log',
{
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
},
account_id: {
allowNull: true,
type: DataTypes.INTEGER,
},
device_id: {
allowNull: true,
type: DataTypes.INTEGER,
},
action: {
allowNull: true,
type: DataTypes.TEXT,
},
user_ip: {
allowNull: true,
type: DataTypes.TEXT,
},
device_ip: {
allowNull: true,
type: DataTypes.TEXT,
},
meta: {
allowNull: true,
type: DataTypes.TEXT,
},
created_at: {
allowNull: true,
type: DataTypes.BIGINT,
},
dongle_id: {
allowNull: true,
type: DataTypes.TEXT,
},
},
account_id: {
allowNull: true,
type: DataTypes.INTEGER,
{
timestamps: false,
},
device_id: {
allowNull: true,
type: DataTypes.INTEGER,
},
action: {
allowNull: true,
type: DataTypes.TEXT,
},
user_ip: {
allowNull: true,
type: DataTypes.TEXT,
},
device_ip: {
allowNull: true,
type: DataTypes.TEXT,
},
meta: {
allowNull: true,
type: DataTypes.TEXT,
},
created_at: {
allowNull: true,
type: DataTypes.BIGINT,
},
dongle_id: {
allowNull: true,
type: DataTypes.TEXT,
},
}, {
timestamps: false,
});
);
};

View File

@ -1,39 +1,41 @@
import { DataTypes } from 'sequelize';
export default (sequelize) => {
sequelize.define('athena_returned_data', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
sequelize.define('athena_returned_data',
{
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
},
device_id: {
allowNull: true,
type: DataTypes.INTEGER,
},
type: {
allowNull: true,
type: DataTypes.TEXT,
},
data: {
allowNull: true,
type: DataTypes.TEXT,
},
created_at: {
allowNull: true,
type: DataTypes.TEXT,
},
uuid: {
allowNull: false,
type: DataTypes.TEXT,
},
resolved_at: {
allowNull: true,
type: DataTypes.INTEGER,
},
},
device_id: {
allowNull: true,
type: DataTypes.INTEGER,
{
timestamps: false,
},
type: {
allowNull: true,
type: DataTypes.TEXT,
},
data: {
allowNull: true,
type: DataTypes.TEXT,
},
created_at: {
allowNull: true,
type: DataTypes.TEXT,
},
uuid: {
allowNull: false,
type: DataTypes.TEXT,
},
resolved_at: {
allowNull: true,
type: DataTypes.INTEGER,
},
}, {
timestamps: false,
});
);
};

View File

@ -1,39 +1,42 @@
import { DataTypes } from 'sequelize';
export default (sequelize) => {
sequelize.define('device_authorised_users', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
sequelize.define(
'device_authorised_users',
{
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
},
account_id: {
allowNull: false,
type: DataTypes.INTEGER,
},
device_id: {
allowNull: true,
type: DataTypes.INTEGER,
},
athena: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
unpair: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
view_drives: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
created_at: {
allowNull: true,
type: DataTypes.BIGINT,
},
},
account_id: {
allowNull: false,
type: DataTypes.INTEGER,
{
timestamps: false,
},
device_id: {
allowNull: true,
type: DataTypes.INTEGER,
},
athena: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
unpair: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
view_drives: {
allowNull: true,
type: DataTypes.BOOLEAN,
},
created_at: {
allowNull: true,
type: DataTypes.BIGINT,
},
}, {
timestamps: false,
});
);
};

View File

@ -46,7 +46,6 @@ export default (sequelize) => {
allowNull: true,
type: DataTypes.INTEGER,
},
max_storage: {
allowNull: true,
type: DataTypes.INTEGER,

View File

@ -16,7 +16,7 @@ const sequelize = new Sequelize({
password: process.env.DB_PASS,
database: process.env.DB_NAME || 'retro-pilot',
host: process.env.DB_HOST || '127.0.0.1',
port: process.env.DB_PORT || 5432,
port: process.env.DB_PORT || 5432,
dialect: 'postgres',
});

View File

@ -1,38 +1,42 @@
import { DataTypes } from 'sequelize';
export default (sequelize) => {
sequelize.define('oauth_accounts', {
id: {
id: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
sequelize.define(
'oauth_accounts',
{
id: {
id: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER,
},
account_id: {
allowNull: false,
type: DataTypes.INTEGER,
},
email: {
allowNull: false,
type: DataTypes.TEXT,
},
created: {
allowNull: true,
type: DataTypes.TIME,
},
last_used: {
allowNull: true,
type: DataTypes.CHAR,
},
refresh: {
allowNull: true,
type: DataTypes.TEXT,
},
provider: {
allowNull: true,
type: DataTypes.TEXT,
},
},
account_id: {
allowNull: false,
type: DataTypes.INTEGER,
{
timestamps: false,
},
email: {
allowNull: false,
type: DataTypes.TEXT,
},
created: {
allowNull: true,
type: DataTypes.TIME,
},
last_used: {
allowNull: true,
type: DataTypes.CHAR,
},
refresh: {
allowNull: true,
type: DataTypes.TEXT,
},
provider: {
allowNull: true,
type: DataTypes.TEXT,
},
}, {
timestamps: false,
});
);
};