307 lines
4.5 KiB
JavaScript
307 lines
4.5 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Integrations = db.integrations;
|
|
|
|
const Sensors = db.sensors;
|
|
|
|
const SystemSettings = db.system_settings;
|
|
|
|
const SystemStatus = db.system_status;
|
|
|
|
const IntegrationsData = [
|
|
{
|
|
connection_status: true,
|
|
|
|
customer_id: 'cust123',
|
|
|
|
server_address: 'thingsboard.example.com',
|
|
|
|
provision_secret: 'secret123',
|
|
|
|
thingsboard_key: 'key123',
|
|
},
|
|
|
|
{
|
|
connection_status: false,
|
|
|
|
customer_id: 'cust456',
|
|
|
|
server_address: 'thingsboard.example.org',
|
|
|
|
provision_secret: 'secret456',
|
|
|
|
thingsboard_key: 'key456',
|
|
},
|
|
|
|
{
|
|
connection_status: true,
|
|
|
|
customer_id: 'cust789',
|
|
|
|
server_address: 'thingsboard.example.net',
|
|
|
|
provision_secret: 'secret789',
|
|
|
|
thingsboard_key: 'key789',
|
|
},
|
|
|
|
{
|
|
connection_status: true,
|
|
|
|
customer_id: 'cust012',
|
|
|
|
server_address: 'thingsboard.example.co',
|
|
|
|
provision_secret: 'secret012',
|
|
|
|
thingsboard_key: 'key012',
|
|
},
|
|
|
|
{
|
|
connection_status: true,
|
|
|
|
customer_id: 'cust345',
|
|
|
|
server_address: 'thingsboard.example.io',
|
|
|
|
provision_secret: 'secret345',
|
|
|
|
thingsboard_key: 'key345',
|
|
},
|
|
];
|
|
|
|
const SensorsData = [
|
|
{
|
|
name: 'Left Scale',
|
|
|
|
type: 'scale',
|
|
|
|
value: 12.5,
|
|
|
|
last_updated: new Date('2023-10-01T10:00:00Z'),
|
|
},
|
|
|
|
{
|
|
name: 'Right Scale',
|
|
|
|
type: 'scale',
|
|
|
|
value: 13,
|
|
|
|
last_updated: new Date('2023-10-01T10:05:00Z'),
|
|
},
|
|
|
|
{
|
|
name: 'Temperature Sensor',
|
|
|
|
type: 'humidity',
|
|
|
|
value: 25.3,
|
|
|
|
last_updated: new Date('2023-10-01T10:10:00Z'),
|
|
},
|
|
|
|
{
|
|
name: 'Humidity Sensor',
|
|
|
|
type: 'temperature',
|
|
|
|
value: 60.2,
|
|
|
|
last_updated: new Date('2023-10-01T10:15:00Z'),
|
|
},
|
|
|
|
{
|
|
name: 'Backup Scale',
|
|
|
|
type: 'scale',
|
|
|
|
value: 11.8,
|
|
|
|
last_updated: new Date('2023-10-01T10:20:00Z'),
|
|
},
|
|
];
|
|
|
|
const SystemSettingsData = [
|
|
{
|
|
system_name: 'Hive Monitor 1',
|
|
|
|
location_text: 'Garden Apiary',
|
|
|
|
latitude: 34.0522,
|
|
|
|
longitude: -118.2437,
|
|
|
|
wifi_ssid: 'BeehiveNet',
|
|
|
|
wifi_password: 'securepassword',
|
|
|
|
ip_mode: 'dhcp',
|
|
|
|
ip_address: '192.168.1.10',
|
|
|
|
sensor_selector: 'none',
|
|
},
|
|
|
|
{
|
|
system_name: 'Hive Monitor 2',
|
|
|
|
location_text: 'Rooftop Apiary',
|
|
|
|
latitude: 40.7128,
|
|
|
|
longitude: -74.006,
|
|
|
|
wifi_ssid: 'HiveNetwork',
|
|
|
|
wifi_password: 'anotherpassword',
|
|
|
|
ip_mode: 'static',
|
|
|
|
ip_address: '192.168.1.11',
|
|
|
|
sensor_selector: 'DHT11',
|
|
},
|
|
|
|
{
|
|
system_name: 'Hive Monitor 3',
|
|
|
|
location_text: 'Field Apiary',
|
|
|
|
latitude: 51.5074,
|
|
|
|
longitude: -0.1278,
|
|
|
|
wifi_ssid: 'FieldNet',
|
|
|
|
wifi_password: 'fieldpassword',
|
|
|
|
ip_mode: 'static',
|
|
|
|
ip_address: '192.168.1.12',
|
|
|
|
sensor_selector: 'DHT11',
|
|
},
|
|
|
|
{
|
|
system_name: 'Hive Monitor 4',
|
|
|
|
location_text: 'Forest Apiary',
|
|
|
|
latitude: 48.8566,
|
|
|
|
longitude: 2.3522,
|
|
|
|
wifi_ssid: 'ForestNet',
|
|
|
|
wifi_password: 'forestpassword',
|
|
|
|
ip_mode: 'static',
|
|
|
|
ip_address: '192.168.1.13',
|
|
|
|
sensor_selector: 'DHT11',
|
|
},
|
|
|
|
{
|
|
system_name: 'Hive Monitor 5',
|
|
|
|
location_text: 'Urban Apiary',
|
|
|
|
latitude: 35.6895,
|
|
|
|
longitude: 139.6917,
|
|
|
|
wifi_ssid: 'UrbanNet',
|
|
|
|
wifi_password: 'urbanpassword',
|
|
|
|
ip_mode: 'static',
|
|
|
|
ip_address: '192.168.1.14',
|
|
|
|
sensor_selector: 'DHT11',
|
|
},
|
|
];
|
|
|
|
const SystemStatusData = [
|
|
{
|
|
wifi_status: 'Connected',
|
|
|
|
wifi_strength: 75,
|
|
|
|
sensor_status: true,
|
|
|
|
thingsboard_status: true,
|
|
},
|
|
|
|
{
|
|
wifi_status: 'Disconnected',
|
|
|
|
wifi_strength: 0,
|
|
|
|
sensor_status: false,
|
|
|
|
thingsboard_status: false,
|
|
},
|
|
|
|
{
|
|
wifi_status: 'Connected',
|
|
|
|
wifi_strength: 85,
|
|
|
|
sensor_status: true,
|
|
|
|
thingsboard_status: true,
|
|
},
|
|
|
|
{
|
|
wifi_status: 'Connected',
|
|
|
|
wifi_strength: 65,
|
|
|
|
sensor_status: true,
|
|
|
|
thingsboard_status: true,
|
|
},
|
|
|
|
{
|
|
wifi_status: 'Disconnected',
|
|
|
|
wifi_strength: 0,
|
|
|
|
sensor_status: false,
|
|
|
|
thingsboard_status: true,
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Integrations.bulkCreate(IntegrationsData);
|
|
|
|
await Sensors.bulkCreate(SensorsData);
|
|
|
|
await SystemSettings.bulkCreate(SystemSettingsData);
|
|
|
|
await SystemStatus.bulkCreate(SystemStatusData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('integrations', null, {});
|
|
|
|
await queryInterface.bulkDelete('sensors', null, {});
|
|
|
|
await queryInterface.bulkDelete('system_settings', null, {});
|
|
|
|
await queryInterface.bulkDelete('system_status', null, {});
|
|
},
|
|
};
|