529 lines
8.9 KiB
JavaScript
529 lines
8.9 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const AuthSessions = db.auth_sessions;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const AuthSessionsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"jwt_id": "sess_9f2c6a1b-1a4d-4f67-9b2a-2c4a7d1e3b90",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-02-20T09:14:22Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expires_at": new Date('2026-02-27T09:14:22Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"revoked": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "203.0.113.10",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Mozilla/5.0 Chrome/121.0",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"jwt_id": "sess_2a7b3c4d-8e19-4b0b-a2b1-6c7d8e9f0a12",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-02-18T21:33:41Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expires_at": new Date('2026-02-25T21:33:41Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"revoked": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "198.51.100.24",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Mozilla/5.0 Firefox/122.0",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"jwt_id": "sess_7c1d9e2f-3a4b-4c5d-8e6f-1a2b3c4d5e6f",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-02-05T12:02:09Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expires_at": new Date('2026-02-12T12:02:09Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"revoked": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "192.0.2.55",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Mozilla/5.0 Safari/17.3",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"jwt_id": "sess_0b12c3d4-e5f6-47a8-9b0c-1d2e3f4a5b6c",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-02-22T07:58:13Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expires_at": new Date('2026-03-01T07:58:13Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"revoked": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "203.0.113.77",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Mozilla/5.0 Edge/121.0",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"jwt_id": "sess_aa11bb22-cc33-44dd-99ee-ff0011223344",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"issued_at": new Date('2026-02-23T18:40:02Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"expires_at": new Date('2026-03-01T18:40:02Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"revoked": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "198.51.100.99",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Mozilla/5.0 Chrome/121.0",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateAuthSessionWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuthSession0 = await AuthSessions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (AuthSession0?.setUser)
|
|
{
|
|
await
|
|
AuthSession0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuthSession1 = await AuthSessions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (AuthSession1?.setUser)
|
|
{
|
|
await
|
|
AuthSession1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuthSession2 = await AuthSessions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (AuthSession2?.setUser)
|
|
{
|
|
await
|
|
AuthSession2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuthSession3 = await AuthSessions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (AuthSession3?.setUser)
|
|
{
|
|
await
|
|
AuthSession3.
|
|
setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuthSession4 = await AuthSessions.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (AuthSession4?.setUser)
|
|
{
|
|
await
|
|
AuthSession4.
|
|
setUser(relatedUser4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await AuthSessions.bulkCreate(AuthSessionsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateAuthSessionWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('auth_sessions', null, {});
|
|
|
|
|
|
},
|
|
}; |