DO $$
DECLARE
max_orderexecuted int;
BEGIN
	max_orderexecuted := (SELECT max(orderexecuted) FROM public.databasechangelog);
insert into
    public.databasechangelog (
    id,
    author,
    filename,
    dateexecuted,
    orderexecuted,
    exectype,
    md5sum,
    description,
    comments,
    tag,
    liquibase,
    contexts,
    labels,
    deployment_id
)
VALUES ('testops-uaa-join-1','charlie','db/changelog/db.changelog-init_uaa_in_report.xml',now()::timestamp,max_orderexecuted + 1,'EXECUTED',null,'sql','migrate UAA to Report',null,'4.12.0',null,null,'9363061597'),
       ('license-details-1','vbragin','db/changelog/db.changelog_license-details.xml',now()::timestamp,max_orderexecuted + 2,'EXECUTED',null,'sql','add license type',null,'4.23.0',null,null,'5842567323'),
       ('license-details-2','vbragin','db/changelog/db.changelog_license-details.xml',now()::timestamp,max_orderexecuted + 3,'EXECUTED',null,'sql','add license_details table',null,'4.23.0',null,null,'5842567323'),
       ('license-details-3','vbragin','db/changelog/db.changelog_license-details.xml',now()::timestamp,max_orderexecuted + 4,'EXECUTED',null,'sql','init license_details table',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-1','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 5,'EXECUTED',null,'sql','rename authority_type',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-2','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 6,'EXECUTED',null,'sql','rename account_authority table',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-3','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 7,'EXECUTED',null,'sql','create new authority_type',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-4','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 8,'EXECUTED',null,'sql','create new account_authority table auditor',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-5','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 9,'EXECUTED',null,'sql','fill account_authority table with data from account_authority_old',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-6','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 10,'EXECUTED',null,'sql','remove bot role and rename auditor',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-7','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 11,'EXECUTED',null,'sql','create view for account with auth',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-8','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 12,'EXECUTED',null,'sql','add default role',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-9','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 13,'EXECUTED',null,'sql','clean old tables 1',null,'4.23.0',null,null,'5842567323'),
       ('cleanup-auth-10','vbragin','db/changelog/db.changelog_cleanup-auth.xml',now()::timestamp,max_orderexecuted + 14,'EXECUTED',null,'sql','clean old tables 2',null,'4.23.0',null,null,'5842567323'),
       ('license-seats-1','vbragin','db/changelog/db.changelog_license-seats.xml',now()::timestamp,max_orderexecuted + 15,'EXECUTED',null,'sql','add license seats info',null,'4.23.0',null,null,'5842567323'),
       ('downgrade-role-1','vbragin','db/changelog/db.changelog_downgrade-role.xml',now()::timestamp,max_orderexecuted + 16,'EXECUTED',null,'sql','create account_downgrade table',null,'4.23.0',null,null,'5842567323'),
       ('downgrade-role-2','vbragin','db/changelog/db.changelog_downgrade-role.xml',now()::timestamp,max_orderexecuted + 17,'EXECUTED',null,'sql','create view for account role and downgrade role',null,'4.23.0',null,null,'5842567323'),
       ('downgrade-role-3','vbragin','db/changelog/db.changelog_downgrade-role.xml',now()::timestamp,max_orderexecuted + 18,'EXECUTED',null,'sql','create invite_downgrade table',null,'4.23.0',null,null,'5842567323'),
       ('downgrade-role-4','vbragin','db/changelog/db.changelog_downgrade-role.xml',now()::timestamp,max_orderexecuted + 19,'EXECUTED',null,'sql','create view for invite role and downgrade role',null,'4.23.0',null,null,'5842567323');
END $$;