mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-20 04:24:23 -08:00
61c6160b98
* Move importer to an inline-template, allows for translations and easier passing of data from laravel to vue. * Pull the modal out into a dedicated partial, move importer to views/importer. * Add document of CSV->importer mappings. Reorganize some code. Progress. * Add header_row and first_row to imports table, and process upon uploading a file * Use an expandable table row instead of a modal for import processing. This should allow for field mapping interaction easier. * Fix import processing after moving method. * Frontend importer mapping improvements. Invert display so we show found columns and allow users to select an importer field to map to. Also implement sample data based on first row of csv. * Update select2. Maintain selected items properly. * Backend support for importing. Only works on the web importer currently. Definitely needs testing and polish. * We no longer use vue-modal plugin. * Add a column to track field mappings to the imports table. * Cleanup/rename methods+refactor * Save field mappings and import type when attempting an import, and repopulate these values when returning to the page. * Update debugbar to fix a bug in the debugbar code. * Fix asset tag detection. Also rename findMatch to be a bit clearer as to what it does. Remove logging to file of imports for http imports because it eats an incredible amouint of memory. This commit also moves imports out of the hardware namespace and into their own webcontroller and route prefix, remove dead code from AssetController as a result. * Dynamically limit options for select2 based on import type selected, and group them by item type. * Add user importer. Still need to implement emailing of passwords to new users, and probably test a bit more. This also bumps the memory limit for web imports up as well, I need to profile memory usage here before too long. * Query the db to find user matches rather than search the array. Performance is much much better. * Speed/memory improvements in importers. Move to querying the db rather than maintaining an array for all importers. Also only store the id of items when we import, rather than the full model. It saves a decent amount of memory. * Remove grouping of items in select2 With the values being set dynamically, the grouping is redundant. It also caused a regression with automatically guessing/matching field names. This is starting to get close. * Remove debug line on every create. * Switch migration to be text field instead of json field for compatibility with older mysql/mariadb * Fix asset import regression matching email address. * Rearrange travis order in attempt to fix null settings. * Use auth::id instead of fetching it off the user. Fixes a null object reference during seeding.
143 lines
6.4 KiB
PHP
143 lines
6.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Accessory;
|
|
use App\Models\Asset;
|
|
use App\Models\AssetModel;
|
|
use App\Models\Category;
|
|
use App\Models\Company;
|
|
use App\Models\Component;
|
|
use App\Models\Consumable;
|
|
use App\Models\Department;
|
|
use App\Models\Depreciation;
|
|
use App\Models\Group;
|
|
use App\Models\Import;
|
|
use App\Models\License;
|
|
use App\Models\LicenseSeat;
|
|
use App\Models\Location;
|
|
use App\Models\Manufacturer;
|
|
use App\Models\Statuslabel;
|
|
use App\Models\Supplier;
|
|
use DB;
|
|
use Illuminate\Console\Command;
|
|
|
|
class PaveIt extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'snipeit:pave
|
|
{--soft : Perform a "Soft" Delete, leaving all migrations, table structure, and the first user in place.}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Pave the database to start over. This should ALMOST NEVER BE USED. (It is primarily a quick tool for developers.)';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
if ($this->confirm("\n****************************************************\nTHIS WILL DELETE ALL OF THE DATA IN YOUR DATABASE. \nThere is NO undo. This WILL destroy ALL of your data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) {
|
|
if ($this->option('soft')) {
|
|
Accessory::getQuery()->delete();
|
|
Asset::getQuery()->delete();
|
|
Category::getQuery()->delete();
|
|
Company::getQuery()->delete();
|
|
Component::getQuery()->delete();
|
|
Consumable::getQuery()->delete();
|
|
Department::getQuery()->delete();
|
|
Depreciation::getQuery()->delete();
|
|
License::getQuery()->delete();
|
|
LicenseSeat::getQuery()->delete();
|
|
Location::getQuery()->delete();
|
|
Manufacturer::getQuery()->delete();
|
|
AssetModel::getQuery()->delete();
|
|
Statuslabel::getQuery()->delete();
|
|
Supplier::getQuery()->delete();
|
|
Group::getQuery()->delete();
|
|
Import::getQuery()->delete();
|
|
|
|
DB::statement('delete from accessories_users');
|
|
DB::statement('delete from asset_logs');
|
|
DB::statement('delete from asset_maintenances');
|
|
DB::statement('delete from asset_uploads');
|
|
DB::statement('delete from action_logs');
|
|
DB::statement('delete from checkout_requests');
|
|
DB::statement('delete from consumables_users');
|
|
DB::statement('delete from custom_field_custom_fieldset');
|
|
DB::statement('delete from custom_fields');
|
|
DB::statement('delete from custom_fieldsets');
|
|
DB::statement('delete from components_assets');
|
|
DB::statement('delete from password_resets');
|
|
DB::statement('delete from requested_assets');
|
|
DB::statement('delete from requests');
|
|
DB::statement('delete from throttle');
|
|
DB::statement('delete from users_groups');
|
|
DB::statement('delete from users WHERE id!=1');
|
|
} else {
|
|
\DB::statement('drop table IF EXISTS accessories_users');
|
|
\DB::statement('drop table IF EXISTS accessories');
|
|
\DB::statement('drop table IF EXISTS asset_logs');
|
|
\DB::statement('drop table IF EXISTS action_logs');
|
|
\DB::statement('drop table IF EXISTS asset_maintenances');
|
|
\DB::statement('drop table IF EXISTS asset_uploads');
|
|
\DB::statement('drop table IF EXISTS assets');
|
|
\DB::statement('drop table IF EXISTS categories');
|
|
\DB::statement('drop table IF EXISTS checkout_requests');
|
|
\DB::statement('drop table IF EXISTS companies');
|
|
\DB::statement('drop table IF EXISTS consumables_users');
|
|
\DB::statement('drop table IF EXISTS consumables');
|
|
\DB::statement('drop table IF EXISTS custom_field_custom_fieldset');
|
|
\DB::statement('drop table IF EXISTS custom_fields');
|
|
\DB::statement('drop table IF EXISTS custom_fieldsets');
|
|
\DB::statement('drop table IF EXISTS depreciations');
|
|
\DB::statement('drop table IF EXISTS departments');
|
|
\DB::statement('drop table IF EXISTS groups');
|
|
\DB::statement('drop table IF EXISTS history');
|
|
\DB::statement('drop table IF EXISTS components');
|
|
\DB::statement('drop table IF EXISTS components_assets');
|
|
\DB::statement('drop table IF EXISTS license_seats');
|
|
\DB::statement('drop table IF EXISTS licenses');
|
|
\DB::statement('drop table IF EXISTS locations');
|
|
\DB::statement('drop table IF EXISTS manufacturers');
|
|
\DB::statement('drop table IF EXISTS models');
|
|
\DB::statement('drop table IF EXISTS migrations');
|
|
\DB::statement('drop table IF EXISTS oauth_access_tokens');
|
|
\DB::statement('drop table IF EXISTS oauth_auth_codes');
|
|
\DB::statement('drop table IF EXISTS oauth_clients');
|
|
\DB::statement('drop table IF EXISTS oauth_personal_access_clients');
|
|
\DB::statement('drop table IF EXISTS oauth_refresh_tokens');
|
|
\DB::statement('drop table IF EXISTS password_resets');
|
|
\DB::statement('drop table IF EXISTS requested_assets');
|
|
\DB::statement('drop table IF EXISTS requests');
|
|
\DB::statement('drop table IF EXISTS settings');
|
|
\DB::statement('drop table IF EXISTS status_labels');
|
|
\DB::statement('drop table IF EXISTS suppliers');
|
|
\DB::statement('drop table IF EXISTS throttle');
|
|
\DB::statement('drop table IF EXISTS users_groups');
|
|
\DB::statement('drop table IF EXISTS users');
|
|
\DB::statement('drop table IF EXISTS imports');
|
|
}
|
|
}
|
|
}
|
|
}
|