Add SQL query for migrating user data from prm_user to new structure
- Created a new SQL file `query_mig_users.sql` to select and transform user data. - The query retrieves user details including user ID, name, email, and various flags. - Includes a commented-out query to count total users per group.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// Change column to nullable
|
||||
$table->string('email', 255)->nullable()->change(); // karena di table LPJ banyak yg NULL
|
||||
$table->char('mig_chg_pass', 1)->nullable()->comment('asal data SYSLOGIN.PRM_USER_ACCESS.CHG_PASS');
|
||||
$table->char('mig_flag_data', 1)->nullable()->comment('asal data SYSLOGIN.PRM_USER.FLAG_DATA. Data ini menunjukkan user pada seluruh aplikasi. Jika berisi 1, maka masih bisa aktif. Jika berisi 0, maka tidak dapat memakai seluruh aplikasi');
|
||||
$table->char('mig_flag_oto', 1)->nullable()->comment('asal data SYSLOGIN.PRM_USER.FLAG_OTO');
|
||||
$table->string('mig_kd_cabang', 11)->nullable()->comment('asal data SYSLOGIN.PRM_USER.KD_CABANG');
|
||||
$table->dateTime('mig_last_change_pass')->nullable()->comment('asal data SYSLOGIN.PRM_USER.LAST_CHANGE_PASS');
|
||||
$table->string('mig_password', 191)->nullable()->comment('asal data SYSLOGIN.PRM_USER.PASSWORD');
|
||||
$table->char('mig_status', 1)->nullable()->comment('asal data SYSLOGIN.PRM_USER_ACCESS.STATUS. Data ini menunjukkan user pada LPJ aplikasi. Jika berisi A, maka masih aktif. Jika berisi 0, maka tidak dapat memakai seluruh aplikasi');
|
||||
$table->dateTime('mig_tgl_oto')->nullable()->comment('asal data SYSLOGIN.PRM_USER.TGL_OTO');
|
||||
$table->dateTime('mig_tgl_update')->nullable()->comment('asal data SYSLOGIN.PRM_USER.TGL_UPDATE');
|
||||
$table->string('mig_user_oto', 10)->nullable()->comment('asal data SYSLOGIN.PRM_USER.USER_OTO');
|
||||
$table->string('mig_user_update', 10)->nullable()->comment('asal data SYSLOGIN.PRM_USER.USER_UPDATE');
|
||||
$table->string('mig_kd_group', 3)->nullable()->comment('asal data SYSLOGIN.PRM_GROUP.KD_GROUP. Berguna untuk INSERT INTO model_has_roles');
|
||||
$table->string('mig_nama_group', 50)->nullable()->comment('asal data SYSLOGIN.PRM_GROUP.NAMA_GROUP. Berguna untuk INSERT INTO model_has_roles');
|
||||
$table->char('is_mig', 1)->nullable()->comment('untuk menandakan row ini dari LPJ OLD');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// Kembalikan kolom 'email' agar tidak nullable lagi (asumsikan sebelumnya NOT NULL)
|
||||
$table->string('email', 255)->nullable(false)->change();
|
||||
|
||||
// Hapus kolom yang ditambahkan di function up()
|
||||
$table->dropColumn([
|
||||
'mig_chg_pass',
|
||||
'mig_flag_data',
|
||||
'mig_flag_oto',
|
||||
'mig_kd_cabang',
|
||||
'mig_last_change_pass',
|
||||
'mig_password',
|
||||
'mig_status',
|
||||
'mig_tgl_oto',
|
||||
'mig_tgl_update',
|
||||
'mig_user_oto',
|
||||
'mig_user_update',
|
||||
'mig_kd_group',
|
||||
'mig_nama_group',
|
||||
'is_mig',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user