Skip to content

Commit

Permalink
✨ Add new tables and progressbar for migration
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Fitz Abucay <ffimnsr@gmail.com>
  • Loading branch information
ffimnsr committed Nov 22, 2024
1 parent a0a80f6 commit 2e2481e
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 347 deletions.
149 changes: 0 additions & 149 deletions .changelog-builder-config.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
**/*.rs.bk
.env
.env.midas
.migration-state
25 changes: 24 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "midas"
version = "0.6.8"
authors = ["Edward Fitz Abucay gh:@ffimnsr"]
version = "0.7.0"
authors = ["Edward Fitz Abucay <gh:@ffimnsr>"]
edition = "2021"
readme = "README.md"
description = "Do painless migration 🦀"
Expand Down Expand Up @@ -44,6 +44,10 @@ thiserror = "2.0.3"
anyhow = "1.0.93"
indicatif = "0.17.9"
indicatif-log-bridge = "0.2.3"
nom = "7.1.3"
serde = { version = "1.0.215", features = ["derive"] }
serde_yaml = "0.9.34"
rand = "0.8.5"

[dev-dependencies]
tempfile = "3.12"
Expand Down
22 changes: 20 additions & 2 deletions midas-rs.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,23 @@
"path": "."
}
],
"settings": {}
}
"settings": {
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
"packages": true
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/.trigger": true,
"target": true,
"packages": true
}
}
}
30 changes: 30 additions & 0 deletions migrations/1567785996234_init_startup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ create extension if not exists pgcrypto;
-- https://docs.postgrest.org/en/v12/explanations/db_authz.html#functions
alter default privileges in schema public revoke execute on functions from PUBLIC;

do $$
begin
create role sesame_su_startup_data nologin;
exception when duplicate_object then raise notice '%, skipping', sqlerrm using errcode = sqlstate;
end
$$;

grant all privileges on database startup to sesame_su_startup_data;
grant all privileges on schema public to sesame_su_startup_data;
grant all privileges on all tables in schema public to sesame_su_startup_data;
Expand All @@ -19,7 +25,13 @@ alter default privileges in schema public grant all on sequences to sesame_su_st
alter default privileges in schema public grant all on functions to sesame_su_startup_data;
alter default privileges in schema public grant all on types to sesame_su_startup_data;

do $$
begin
create role sesame_read_startup_data nologin;
exception when duplicate_object then raise notice '%, skipping', sqlerrm using errcode = sqlstate;
end
$$;

grant usage on schema public to sesame_read_startup_data;
grant select on all tables in schema public to sesame_read_startup_data;
grant usage, select on all sequences in schema public to sesame_read_startup_data;
Expand All @@ -28,7 +40,13 @@ alter default privileges in schema public grant select on tables to sesame_read_
alter default privileges in schema public grant usage, select on sequences to sesame_read_startup_data;
alter default privileges in schema public grant execute on functions to sesame_read_startup_data;

do $$
begin
create role sesame_write_startup_data nologin;
exception when duplicate_object then raise notice '%, skipping', sqlerrm using errcode = sqlstate;
end
$$;

grant usage on schema public to sesame_write_startup_data;
grant insert, update, delete on all tables in schema public to sesame_write_startup_data;
grant usage, update on all sequences in schema public to sesame_write_startup_data;
Expand All @@ -37,11 +55,23 @@ alter default privileges in schema public grant insert, update, delete on tables
alter default privileges in schema public grant usage, update on sequences to sesame_write_startup_data;
alter default privileges in schema public grant execute on functions to sesame_write_startup_data;

do $$
begin
create role webuser nologin;
exception when duplicate_object then raise notice '%, skipping', sqlerrm using errcode = sqlstate;
end
$$;

grant sesame_read_startup_data to webuser;
grant sesame_write_startup_data to webuser;

do $$
begin
create role anon nologin;
exception when duplicate_object then raise notice '%, skipping', sqlerrm using errcode = sqlstate;
end
$$;

grant sesame_read_startup_data to anon;

create or replace function get_user_uid()
Expand Down
1 change: 1 addition & 0 deletions migrations/1732119785927_alter_type_salary_detail.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ alter type new_salary_detail rename to salary_detail;
alter table jobs alter column salary set default row('5', '10', 'USD', 'hourly')::salary_detail;
update jobs set salary = row('5', '10', 'USD', 'hourly')::salary_detail where salary is null;


-- !DOWN

-- No down migration for this migration
Loading

0 comments on commit 2e2481e

Please sign in to comment.