「Tep3-onk」の版間の差分

提供: wikipokpok
移動先: 案内検索
(postgres)
(postgres)
72行目: 72行目:
 
UPDATE 3066</nowiki>
 
UPDATE 3066</nowiki>
  
  <nowiki>=# COPY (SELECT user_id,jiin_id,ie_id,name,yomi,nusi,each_order,memo,generation,created_at,updated_at FROM jq_clients WHERE jiin_id = 1) TO '/Users/jq/rails_app_tepnote/jq_clients.csv' WITH CSV HEADER;
+
  <nowiki>=# COPY (SELECT userid,jiinid,ie_id,name,yomi,nusi,each_order,memo,generation,created_at,updated_at FROM jq_clients WHERE jiin_id = 1) TO '/Users/jq/rails_app_tepnote/jq_clients.csv' WITH CSV HEADER;
 
COPY 3066</nowiki>
 
COPY 3066</nowiki>
  

2022年9月12日 (月) 17:43時点における版

generate

$ rails generate scaffold User name:string email:string password_digest:string remember_digest:string admin:boolean activation_digest:string activated:boolean activated_at:datetime reset_digest:string reset_sent_at:datetime
$ rails generate scaffold User name:string email:string password_digest:string remember_digest:string role:integer activation_digest:string activated:boolean activated_at:datetime reset_digest:string reset_sent_at:datetime
% rails generate scaffold Note content:string user:references kind:integer meeting_time:integer role:integer line:integer
% rails generate scaffold Client user:references note:references content:string list:integer line:integer memo:text
% rails generate scaffold Other user:references note:references client:references name:string yomi:string client_name:boolean line:integer memo:text generation:string
$ rails generate scaffold Post content:text user:references picture:string
$ rails generate model Relationship follower_id:integer followed_id:integer
$ rails db:migrate RAILS_ENV=production
$ bin/dev
$ rails generate controller StaticPages home help about contact

エラー

ActionView::Template::Error (The asset "tailwind.css" is not present in the asset pipeline.

config/envitonments/production.rb

config.assets.compile = true

db:rollback

% rails db:migrate:status
% rails db:rollback STEP=3
% rails db:migrate
$ rails db:migrate:down VERSION=20200504051127
$ rails db:migrate:up VERSION=20200504051127

postgres

$ heroku pg:backups:capture
$ heroku pg:backups:download
$ createdb mydb
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
=# select count(*) from clients;
 count 
-------
  4209
(1 row)

=# select distinct on (jiin_id) * from clients;

テーブルをコピーしてデータを加工する

=# CREATE TABLE jq_clients AS SELECT * FROM clients where jiin_id = 1;
SELECT 3066
=# ALTER TABLE jq_clients ADD COLUMN userid uuid;
=# update jq_clients SET userid = '44f47a1e-2ccf-4213-bac5-aa62c5f3c141';
UPDATE 3066

=# ALTER TABLE jq_clients ADD COLUMN jiinid uuid;
=# update jq_clients SET jiinid = 'd23ae9b5-5a74-4e95-9933-0e710b13401a';
UPDATE 3066
=# update jq_clients SET ie_id = null;
UPDATE 3066
=# COPY (SELECT userid,jiinid,ie_id,name,yomi,nusi,each_order,memo,generation,created_at,updated_at FROM jq_clients WHERE jiin_id = 1) TO '/Users/jq/rails_app_tepnote/jq_clients.csv' WITH CSV HEADER;
COPY 3066

ローカル

rubyの確認

プロジェクトディレクトリに移動

% cd rails_app_tepnote/3tep

カレントディレクトリでrubyのバージョン確認

% rbenv version            
2.7.1 (set by /Users/jq/.rbenv/version)

使用できるrubyのバージョン確認

% rbenv versions
  system
  2.6.6
* 2.7.1 (set by /Users/jq/.rbenv/version)
  2.7.4
  2.7.5
  3.0.0
  3.1.2

カレントディレクトリで使う rubyのバージョンを指定する

% rbenv local 3.1.2

確認 2.7.1から3.1.2に変わった

% rbenv version    
3.1.2 (set by /Users/jq/rails_app_tepnote/3tep/.ruby-version)

% rbenv versions
  system
  2.6.6
  2.7.1
  2.7.4
  2.7.5
  3.0.0
* 3.1.2 (set by /Users/jq/rails_app_tepnote/3tep/.ruby-version)

railsの確認

カレントディレクトリで確認 無かったのでインストールする

% rails -v
rbenv: rails: command not found
% gem install rails
% rails -v         
Rails 7.0.3.1

bundlerの確認

% gem search ^bundler$ --all
bundler (2.3.21, 2.3.20, 2.3.19, 2.3.18, 2.3.17,.......
% gem list bundler

*** LOCAL GEMS ***

bundler (2.2.17, default: 2.1.4)

バージョンを指定してインストール

% gem install bundler -v 2.3.21

確認

% gem list bundler             

*** LOCAL GEMS ***

bundler (2.3.21, 2.2.17, default: 2.1.4
% bundle -v
Bundler version 2.3.21

postgresqlの確認

% psql --version
psql (PostgreSQL) 14.5 (Homebrew)

new

% rails new tep30 -d postgresql --css tailwind または rails new tep30 -d postgresql --css bootstrap
% cd tep30
% bundle install
% rails db:create
% rails db:migrate
% rails s

daisyui

tailwind css UIコンポーネント インストール

% yarn add daisyui

コピー

% scp -r --exclude-from='exclude-file.txt' ~/rails_app_tepnote/3tep/tep30 xxx:/home/xxx

ホスト

確認

$ ruby -v
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
$ rails -v
Rails 7.0.3.1
$ bundle -v
Bundler version 2.3.21
$ psql --version

new

$ rails new tep30 -d postgresql --css bootstrap または rails new tep30 --css tailwind -d postgresql

database.yml username:などを確認する (2箇所)

$ bundle install --without test development
$ rails db:create RAILS_ENV=production
$ rails db:migrate RAILS_ENV=production

daisyuiをインストール

$ yarn add daisyui

config/tailwind.config.js

plugins: [
    require('@tailwindcss/forms'),
    require('@tailwindcss/aspect-ratio'),
    require('@tailwindcss/typography'),
    require('daisyui'),    // ← 追記する
  ],

app/views/layouts/application.html.erb

<html data-theme="light">  // テーマを選ぶ


同期

% rsync -r ~/rails_app_tepnote/4tep/ host:/home/tep/

除外するファイルをまとめる

exclude-file.txt
    production.rb
    database.yml
% rsync -r --exclude-from='exclude-file.txt' ~/rails_app_tepnote/tep5/ jq:/home/jq/tep5/


$ bundle install  --without test development

database.yml username:などを確認する (2箇所)

$ rails db:create RAILS_ENV=production
または
$ rails db:reset RAILS_ENV=production

エラーのとき

ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit`

master.key credentials.yml.enc 削除して作り直す

$ EDITOR="vi" bin/rails credentials:edit
$ rails db:migrate RAILS_ENV=production

エラー

ActionView::Template::Error (The asset "tailwind.css" is not present in the asset pipeline.

config/envitonments/production.rb

config.assets.compile = true

daisyuiをインストール

$ yarn add daisyui