add custom_domain (default to NULL) to schema
This commit is contained in:
		
							parent
							
								
									fb60236a54
								
							
						
					
					
						commit
						6bcc4f0ab0
					
				| @ -0,0 +1,2 @@ | |||||||
|  | -- undo the adding of custom_domain column to blogs table. | ||||||
|  | ALTER TABLE blogs DROP COLUMN custom_domain; | ||||||
| @ -0,0 +1,2 @@ | |||||||
|  | --- Adding custom domain to Blog as an optional field | ||||||
|  | ALTER TABLE blogs ADD COLUMN custom_domain VARCHAR DEFAULT NULL UNIQUE; | ||||||
| @ -0,0 +1,56 @@ | |||||||
|  | -- undo the adding of "custom_domain" to blogs | ||||||
|  | CREATE TABLE IF NOT EXISTS "blogs_drop_custom_domain" ( | ||||||
|  |   id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||||||
|  |   actor_id VARCHAR NOT NULL, | ||||||
|  |   title VARCHAR NOT NULL, | ||||||
|  |   summary TEXT NOT NULL DEFAULT '', | ||||||
|  |   outbox_url VARCHAR NOT NULL UNIQUE, | ||||||
|  |   inbox_url VARCHAR NOT NULL UNIQUE, | ||||||
|  |   instance_id INTEGER REFERENCES instances(id) ON DELETE CASCADE NOT NULL, | ||||||
|  |   creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||||
|  |   ap_url text not null default '' UNIQUE, | ||||||
|  |   private_key TEXT, | ||||||
|  |   public_key TEXT NOT NULL DEFAULT '', | ||||||
|  |   fqn TEXT NOT NULL DEFAULT '', | ||||||
|  |   summary_html TEXT NOT NULL DEFAULT '', | ||||||
|  |   icon_id INTEGER REFERENCES medias(id) ON DELETE SET NULL DEFAULT NULL, | ||||||
|  |   banner_id INTEGER REFERENCES medias(id) ON DELETE SET NULL DEFAULT NULL, | ||||||
|  |   CONSTRAINT blog_unique UNIQUE (actor_id, instance_id) | ||||||
|  | ); | ||||||
|  | 
 | ||||||
|  | INSERT INTO blogs_drop_custom_domain ( | ||||||
|  |   id, | ||||||
|  |   actor_id, | ||||||
|  |   title, | ||||||
|  |   summary, | ||||||
|  |   outbox_url, | ||||||
|  |   inbox_url, | ||||||
|  |   instance_id, | ||||||
|  |   creation_date, | ||||||
|  |   ap_url, | ||||||
|  |   private_key, | ||||||
|  |   public_key, | ||||||
|  |   fqn, | ||||||
|  |   summary_html, | ||||||
|  |   icon_id, | ||||||
|  |   banner_id | ||||||
|  | ) SELECT | ||||||
|  |   id, | ||||||
|  |   actor_id, | ||||||
|  |   title, | ||||||
|  |   summary, | ||||||
|  |   outbox_url, | ||||||
|  |   inbox_url, | ||||||
|  |   instance_id, | ||||||
|  |   creation_date, | ||||||
|  |   ap_url, | ||||||
|  |   private_key, | ||||||
|  |   public_key, | ||||||
|  |   fqn, | ||||||
|  |   summary_html, | ||||||
|  |   icon_id, | ||||||
|  |   banner_id | ||||||
|  | FROM blogs; | ||||||
|  | 
 | ||||||
|  | DROP TABLE blogs; | ||||||
|  | ALTER TABLE "blogs_drop_custom_domain" RENAME to blogs; | ||||||
| @ -0,0 +1,57 @@ | |||||||
|  | -- add custom_domain to blogs | ||||||
|  | CREATE TABLE IF NOT EXISTS "blogs_add_custom_domain" ( | ||||||
|  |   id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||||||
|  |   actor_id VARCHAR NOT NULL, | ||||||
|  |   title VARCHAR NOT NULL, | ||||||
|  |   summary TEXT NOT NULL DEFAULT '', | ||||||
|  |   outbox_url VARCHAR NOT NULL UNIQUE, | ||||||
|  |   inbox_url VARCHAR NOT NULL UNIQUE, | ||||||
|  |   instance_id INTEGER REFERENCES instances(id) ON DELETE CASCADE NOT NULL, | ||||||
|  |   creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||||||
|  |   ap_url text not null default '' UNIQUE, | ||||||
|  |   private_key TEXT, | ||||||
|  |   public_key TEXT NOT NULL DEFAULT '', | ||||||
|  |   fqn TEXT NOT NULL DEFAULT '', | ||||||
|  |   summary_html TEXT NOT NULL DEFAULT '', | ||||||
|  |   icon_id INTEGER REFERENCES medias(id) ON DELETE SET NULL DEFAULT NULL, | ||||||
|  |   banner_id INTEGER REFERENCES medias(id) ON DELETE SET NULL DEFAULT NULL, | ||||||
|  |   custom_domain text default NULL UNIQUE, | ||||||
|  |   CONSTRAINT blog_unique UNIQUE (actor_id, instance_id) | ||||||
|  | ); | ||||||
|  | 
 | ||||||
|  | INSERT INTO blogs_add_custom_domain ( | ||||||
|  |   id, | ||||||
|  |   actor_id, | ||||||
|  |   title, | ||||||
|  |   summary, | ||||||
|  |   outbox_url, | ||||||
|  |   inbox_url, | ||||||
|  |   instance_id, | ||||||
|  |   creation_date, | ||||||
|  |   ap_url, | ||||||
|  |   private_key, | ||||||
|  |   public_key, | ||||||
|  |   fqn, | ||||||
|  |   summary_html, | ||||||
|  |   icon_id, | ||||||
|  |   banner_id | ||||||
|  | ) SELECT | ||||||
|  |   id, | ||||||
|  |   actor_id, | ||||||
|  |   title, | ||||||
|  |   summary, | ||||||
|  |   outbox_url, | ||||||
|  |   inbox_url, | ||||||
|  |   instance_id, | ||||||
|  |   creation_date, | ||||||
|  |   ap_url, | ||||||
|  |   private_key, | ||||||
|  |   public_key, | ||||||
|  |   fqn, | ||||||
|  |   summary_html, | ||||||
|  |   icon_id, | ||||||
|  |   banner_id | ||||||
|  | FROM blogs; | ||||||
|  | 
 | ||||||
|  | DROP TABLE blogs; | ||||||
|  | ALTER TABLE "blogs_add_custom_domain" RENAME to blogs; | ||||||
| @ -44,6 +44,7 @@ pub struct Blog { | |||||||
|     pub summary_html: SafeString, |     pub summary_html: SafeString, | ||||||
|     pub icon_id: Option<i32>, |     pub icon_id: Option<i32>, | ||||||
|     pub banner_id: Option<i32>, |     pub banner_id: Option<i32>, | ||||||
|  |     pub custom_domain: Option<String>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Default, Insertable)] | #[derive(Default, Insertable)] | ||||||
| @ -61,6 +62,7 @@ pub struct NewBlog { | |||||||
|     pub summary_html: SafeString, |     pub summary_html: SafeString, | ||||||
|     pub icon_id: Option<i32>, |     pub icon_id: Option<i32>, | ||||||
|     pub banner_id: Option<i32>, |     pub banner_id: Option<i32>, | ||||||
|  |     pub custom_domain: Option<String>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const BLOG_PREFIX: &str = "~"; | const BLOG_PREFIX: &str = "~"; | ||||||
| @ -392,6 +394,7 @@ impl FromId<PlumeRocket> for Blog { | |||||||
|                         .summary_string() |                         .summary_string() | ||||||
|                         .unwrap_or_default(), |                         .unwrap_or_default(), | ||||||
|                 ), |                 ), | ||||||
|  |                 custom_domain: None, | ||||||
|             }, |             }, | ||||||
|         ) |         ) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,17 +1,17 @@ | |||||||
| table! { | table! { | ||||||
|     api_tokens (id) { |     api_tokens (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
|         value -> Text, |         value -> Text, | ||||||
|         scopes -> Text, |         scopes -> Text, | ||||||
|         app_id -> Int4, |         app_id -> Integer, | ||||||
|         user_id -> Int4, |         user_id -> Integer, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     apps (id) { |     apps (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         name -> Text, |         name -> Text, | ||||||
|         client_id -> Text, |         client_id -> Text, | ||||||
|         client_secret -> Text, |         client_secret -> Text, | ||||||
| @ -23,70 +23,71 @@ table! { | |||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     blog_authors (id) { |     blog_authors (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         blog_id -> Int4, |         blog_id -> Integer, | ||||||
|         author_id -> Int4, |         author_id -> Integer, | ||||||
|         is_owner -> Bool, |         is_owner -> Bool, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     blogs (id) { |     blogs (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         actor_id -> Varchar, |         actor_id -> Text, | ||||||
|         title -> Varchar, |         title -> Text, | ||||||
|         summary -> Text, |         summary -> Text, | ||||||
|         outbox_url -> Varchar, |         outbox_url -> Text, | ||||||
|         inbox_url -> Varchar, |         inbox_url -> Text, | ||||||
|         instance_id -> Int4, |         instance_id -> Integer, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
|         ap_url -> Text, |         ap_url -> Text, | ||||||
|         private_key -> Nullable<Text>, |         private_key -> Nullable<Text>, | ||||||
|         public_key -> Text, |         public_key -> Text, | ||||||
|         fqn -> Text, |         fqn -> Text, | ||||||
|         summary_html -> Text, |         summary_html -> Text, | ||||||
|         icon_id -> Nullable<Int4>, |         icon_id -> Nullable<Integer>, | ||||||
|         banner_id -> Nullable<Int4>, |         banner_id -> Nullable<Integer>, | ||||||
|  |         custom_domain -> Nullable<Text>, | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | table! { | ||||||
|  |     comment_seers (id) { | ||||||
|  |         id -> Integer, | ||||||
|  |         comment_id -> Integer, | ||||||
|  |         user_id -> Integer, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     comments (id) { |     comments (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         content -> Text, |         content -> Text, | ||||||
|         in_response_to_id -> Nullable<Int4>, |         in_response_to_id -> Nullable<Integer>, | ||||||
|         post_id -> Int4, |         post_id -> Integer, | ||||||
|         author_id -> Int4, |         author_id -> Integer, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
|         ap_url -> Nullable<Varchar>, |         ap_url -> Nullable<Text>, | ||||||
|         sensitive -> Bool, |         sensitive -> Bool, | ||||||
|         spoiler_text -> Text, |         spoiler_text -> Text, | ||||||
|         public_visibility -> Bool, |         public_visibility -> Bool, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { |  | ||||||
|     comment_seers (id) { |  | ||||||
|         id -> Int4, |  | ||||||
|         comment_id -> Int4, |  | ||||||
|         user_id -> Int4, |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| table! { | table! { | ||||||
|     follows (id) { |     follows (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         follower_id -> Int4, |         follower_id -> Integer, | ||||||
|         following_id -> Int4, |         following_id -> Integer, | ||||||
|         ap_url -> Text, |         ap_url -> Text, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     instances (id) { |     instances (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         public_domain -> Varchar, |         public_domain -> Text, | ||||||
|         name -> Varchar, |         name -> Text, | ||||||
|         local -> Bool, |         local -> Bool, | ||||||
|         blocked -> Bool, |         blocked -> Bool, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
| @ -94,50 +95,50 @@ table! { | |||||||
|         short_description -> Text, |         short_description -> Text, | ||||||
|         long_description -> Text, |         long_description -> Text, | ||||||
|         default_license -> Text, |         default_license -> Text, | ||||||
|         long_description_html -> Varchar, |         long_description_html -> Text, | ||||||
|         short_description_html -> Varchar, |         short_description_html -> Text, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     likes (id) { |     likes (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         user_id -> Int4, |         user_id -> Integer, | ||||||
|         post_id -> Int4, |         post_id -> Integer, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
|         ap_url -> Varchar, |         ap_url -> Text, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     medias (id) { |     medias (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         file_path -> Text, |         file_path -> Text, | ||||||
|         alt_text -> Text, |         alt_text -> Text, | ||||||
|         is_remote -> Bool, |         is_remote -> Bool, | ||||||
|         remote_url -> Nullable<Text>, |         remote_url -> Nullable<Text>, | ||||||
|         sensitive -> Bool, |         sensitive -> Bool, | ||||||
|         content_warning -> Nullable<Text>, |         content_warning -> Nullable<Text>, | ||||||
|         owner_id -> Int4, |         owner_id -> Integer, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     mentions (id) { |     mentions (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         mentioned_id -> Int4, |         mentioned_id -> Integer, | ||||||
|         post_id -> Nullable<Int4>, |         post_id -> Nullable<Integer>, | ||||||
|         comment_id -> Nullable<Int4>, |         comment_id -> Nullable<Integer>, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     notifications (id) { |     notifications (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         user_id -> Int4, |         user_id -> Integer, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
|         kind -> Varchar, |         kind -> Text, | ||||||
|         object_id -> Int4, |         object_id -> Integer, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -152,67 +153,67 @@ table! { | |||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     post_authors (id) { |     post_authors (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         post_id -> Int4, |         post_id -> Integer, | ||||||
|         author_id -> Int4, |         author_id -> Integer, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     posts (id) { |     posts (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         blog_id -> Int4, |         blog_id -> Integer, | ||||||
|         slug -> Varchar, |         slug -> Text, | ||||||
|         title -> Varchar, |         title -> Text, | ||||||
|         content -> Text, |         content -> Text, | ||||||
|         published -> Bool, |         published -> Bool, | ||||||
|         license -> Varchar, |         license -> Text, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
|         ap_url -> Varchar, |         ap_url -> Text, | ||||||
|         subtitle -> Text, |         subtitle -> Text, | ||||||
|         source -> Text, |         source -> Text, | ||||||
|         cover_id -> Nullable<Int4>, |         cover_id -> Nullable<Integer>, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     reshares (id) { |     reshares (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         user_id -> Int4, |         user_id -> Integer, | ||||||
|         post_id -> Int4, |         post_id -> Integer, | ||||||
|         ap_url -> Varchar, |         ap_url -> Text, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     tags (id) { |     tags (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         tag -> Text, |         tag -> Text, | ||||||
|         is_hashtag -> Bool, |         is_hashtag -> Bool, | ||||||
|         post_id -> Int4, |         post_id -> Integer, | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table! { | table! { | ||||||
|     users (id) { |     users (id) { | ||||||
|         id -> Int4, |         id -> Integer, | ||||||
|         username -> Varchar, |         username -> Text, | ||||||
|         display_name -> Varchar, |         display_name -> Text, | ||||||
|         outbox_url -> Varchar, |         outbox_url -> Text, | ||||||
|         inbox_url -> Varchar, |         inbox_url -> Text, | ||||||
|         is_admin -> Bool, |         is_admin -> Bool, | ||||||
|         summary -> Text, |         summary -> Text, | ||||||
|         email -> Nullable<Text>, |         email -> Nullable<Text>, | ||||||
|         hashed_password -> Nullable<Text>, |         hashed_password -> Nullable<Text>, | ||||||
|         instance_id -> Int4, |         instance_id -> Integer, | ||||||
|         creation_date -> Timestamp, |         creation_date -> Timestamp, | ||||||
|         ap_url -> Text, |         ap_url -> Text, | ||||||
|         private_key -> Nullable<Text>, |         private_key -> Nullable<Text>, | ||||||
|         public_key -> Text, |         public_key -> Text, | ||||||
|         shared_inbox_url -> Nullable<Varchar>, |         shared_inbox_url -> Nullable<Text>, | ||||||
|         followers_endpoint -> Varchar, |         followers_endpoint -> Text, | ||||||
|         avatar_id -> Nullable<Int4>, |         avatar_id -> Nullable<Integer>, | ||||||
|         last_fetched_date -> Timestamp, |         last_fetched_date -> Timestamp, | ||||||
|         fqn -> Text, |         fqn -> Text, | ||||||
|         summary_html -> Text, |         summary_html -> Text, | ||||||
| @ -248,8 +249,8 @@ allow_tables_to_appear_in_same_query!( | |||||||
|     apps, |     apps, | ||||||
|     blog_authors, |     blog_authors, | ||||||
|     blogs, |     blogs, | ||||||
|     comments, |  | ||||||
|     comment_seers, |     comment_seers, | ||||||
|  |     comments, | ||||||
|     follows, |     follows, | ||||||
|     instances, |     instances, | ||||||
|     likes, |     likes, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user