1#[cfg(feature = "account-data")]
7mod account_data;
8mod acting;
9mod invitation;
10mod members;
11mod organization;
12mod organizations;
13
14use sofie::db::Migrations;
15
16#[cfg(feature = "account-data")]
17pub use account_data::OrganizationMemberships;
18pub use acting::Acting;
19pub use invitation::Invitation;
20pub use members::{ROUTES as ORGANIZATION_ROUTES, routes as organization_routes};
21pub use organization::{
22 MemberJoined, MemberLeft, MemberRoleChanged, Organization, OrganizationArea,
23 OrganizationDeleted, OrganizationId, OrganizationMember, OrganizationRole,
24};
25pub use organizations::{ROUTES as MEMBER_ROUTES, routes as member_routes};
26
27const MODULE_NAME: &str = "sofie_tenancy";
28
29pub const MODULE: sofie::http::Module = sofie::http::Module {
31 migrations: Some(migrations()),
32 #[cfg(feature = "billing")]
33 jobs: worker,
34 ..sofie::http::Module::new(MODULE_NAME)
35};
36
37#[cfg(feature = "billing")]
38#[must_use]
39pub fn worker(worker: sofie::worker::Worker) -> sofie::worker::Worker {
40 worker.on::<sofie::billing::SubscriptionChanged, _>(
41 "sofie_tenancy.cancel_deleted_plan",
42 organization::cancel_deleted_plan,
43 )
44}
45
46#[must_use]
47pub const fn migrations() -> Migrations {
48 Migrations::new(
49 MODULE_NAME,
50 sofie::db::embed!(
51 "migrations",
52 [
53 "0000_module_role.sql",
54 "0001_organizations.sql",
55 "0002_organization_deleted.sql"
56 ]
57 ),
58 )
59 .sqlite(sofie::db::embed!(
60 "migrations/sqlite",
61 [
62 "0000_module_role.sql",
63 "0001_organizations.sql",
64 "0002_organization_deleted.sql"
65 ]
66 ))
67 .aggregates(AGGREGATES)
68}
69
70const AGGREGATES: &[sofie::db::AggregateTable] = &[
71 sofie::db::AggregateTable::of::<Organization>(),
72 sofie::db::AggregateTable::of::<OrganizationMember>(),
73 sofie::db::AggregateTable::of::<Invitation>(),
74];