# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-09-07 02:19
from __future__ import unicode_literals
from django.db import migrations


class Migration(migrations.Migration):

    dependencies = [("chroma_core", "0002_remove_stat_pks")]

    operations = [
        migrations.RunSQL(
            sql="""
CREATE OR REPLACE FUNCTION api_key(
    OUT username text,
    OUT key text
) AS
$func$
BEGIN
    SELECT ta.key, au.username
    INTO key, username
    FROM auth_user as au
    INNER JOIN tastypie_apikey as ta on au.id = ta.user_id
    WHERE au.username = 'api';
END
$func$ LANGUAGE plpgsql;
        """,
            reverse_sql="DROP FUNCTION IF EXISTS api_key();",
        )
    ]
