SIWECOS / siwecos-business-layer

SIWECOS Main API and Business Layer Application
https://siwecos.de
0 stars 1 forks source link

Datenbank zur v2 migrieren #128

Closed Lednerb closed 5 years ago

Lednerb commented 5 years ago

Ein entsprechendes Datenbank-Migrationsscript muss erstellt werden

Skeeve commented 5 years ago

Vorgehensweise am Besten:

  1. Neue DB siwecos_bla erstellen
  2. Tabellen anlegen
  3. Angehängte SQL Queries ausführen migrate.zip
Skeeve commented 5 years ago

agb_check dazu:

insert into users (  id, email, password, is_active, agb_check, preferred_language, activation_key, passwordreset_token, token_id,   created_at,   updated_at)
           select  U.id, email, password, U.active,  agb,       preferred_language, activation_key, passwordreset_token, T.id,     U.created_at, U.updated_at
           from    business_api.users U
           join    core_api.tokens T
           on      (T.token = U.token)
Skeeve commented 5 years ago

Letztlich verwendete Scripte:

insert into domains (id, token_id, domain, is_verified, verification_token, created_at, updated_at)
             select  id, token_id, domain, verified,    domain_token,       created_at, updated_at
             from    core_api.domains
             where   domain_token is not null
insert into tokens (id, token, credits, type,      created_at, updated_at)
            select  id, token, credits, "regular", created_at, updated_at
            from    core_api.tokens
insert into users (  id, email, password, is_active, preferred_language, activation_key, passwordreset_token, token_id,   created_at,   updated_at)
           select  U.id, email, password, U.active,  preferred_language, activation_key, passwordreset_token, T.id,     U.created_at, U.updated_at
           from    business_api.users U
           join    core_api.tokens T
           on      (T.token = U.token)
Lednerb commented 5 years ago

php artisan tinker - Script zum Umwandeln der URLs zu Domains (Hostnames) incl. entfernen von Duplikaten durch Registrierung via https:// und http://:

Domains::all()->each(function ($d) {
    $domain = parse_url($d->domain, PHP_URL_HOST);
    try {
        if($domain) $d->update(['domain' => $domain]);   
    } catch(\Illuminate\Database\QueryException $e) {
        $d->delete();
    }
});
Lednerb commented 5 years ago

Stand v2 Datenbank-Struktur

database.zip